SPI_Asm bug

My code works with SPI_Spin but not SPI_Asm…

I'm interfacing a Prop with EVE2 based display module.
It's regular SPI, but with 32 bit packet size.


I found the bug (I'm going to call this a bug) in the assembly code, in the MSBFirst_ section:
shl     t5,             arg3              ''          Shift "1" N number of bits to the left.


LSB first works, but MSB first does not for bits=32

This messed me up pretty good, had to break out oscilloscope to figure out what is going on...
Prop Info and Apps: http://www.rayslogic.com/

Comments

  • This version may have bug fixed.
    Seems to work for me anyway...
    Prop Info and Apps: http://www.rayslogic.com/
  • Hmm, I can't confirm that particular case as I don't have one, but the change breaks an ssd1331 object for me, vs the original SPI_Asm object, or the spin-standard-library rewrite of it (com.spi.spin), though the 1331 doesn't need the 32bit transaction capability. Maybe this would just be more of an EVE2-specific SPI driver...or maybe there's a way to get it to work with other devices and I'm just not experienced enough ;)
    --
    WIP Spin drivers for various devices: lsm9ds1 IMU (SPI), Newhaven 4x20 OLED (I2C), Melexis 90621 Thermal imager (I2C), SHT3x Temp/RH (I2C), SSD1306 OLED (I2C), AMS TCS3x7x RGB Color Sensor (I2C), MAX31856 Thermocouple Amp (SPI), BMP280 Baro. Press/Temp (I2C), Trinamic TMC2130 Stepper Driver (SPI)
  • Yeah, my driver doesn't work for me anymore either...
    Maybe only 32-bit transfers work...
    I think I'll just make a new one that does only what I need...
    Prop Info and Apps: http://www.rayslogic.com/
  • kuroneko gave me some code to fix this, see attached, seems to work now.
    Prop Info and Apps: http://www.rayslogic.com/
  • Confirmed here too...thanks Ray and kuroneko!
    --
    WIP Spin drivers for various devices: lsm9ds1 IMU (SPI), Newhaven 4x20 OLED (I2C), Melexis 90621 Thermal imager (I2C), SHT3x Temp/RH (I2C), SSD1306 OLED (I2C), AMS TCS3x7x RGB Color Sensor (I2C), MAX31856 Thermocouple Amp (SPI), BMP280 Baro. Press/Temp (I2C), Trinamic TMC2130 Stepper Driver (SPI)
Sign In or Register to comment.