my project has multiple spi devices connected to the atmega 328. I have tested individual programs to run each device and have them functioning perfectly. Now I am beginning to write code to run all the devices. But, one of the devices is LSB first and it cannot be changed. The other devices are MSB first.
It seems the SPI library functionSPI.setBitOrder(LSBFIRST)only has effect if it is run before SPI.begin()
I attempted to change bit order every time I wanted to communicate with a different device but that doesnt seem to work. I was wondering if anyone else had this problem and had any suggestions on how to deal with it.
I am thinking I may be able to run the SPI.begin() function every time I change bit orders, but that seems clunky.
And the datasheet makes no mention of a restrictive mode...
• Bit 5 – DORD: Data Order
When the DORD bit is written to one, the LSB of the data word is transmitted first.
When the DORD bit is written to zero, the MSB of the data word is transmitted first.
my project has multiple spi devices connected to the atmega 328. I have tested individual programs to run each device and have them functioning perfectly. Now I am beginning to write code to run all the devices. But, one of the devices is LSB first and it cannot be changed. The other devices are MSB first.
So? Just change the SPI bit order as needed (ie. SPI.setBitOrder())
I made my own library with a bunch of functions and at the end of each function for the LSB device I would end it by setting bit order back to MSBfirst. But, some of my functions called other functions for the same device and would switch back to MSB too early