2007-11-22 02:19 AM
SPI for 25bit datastream
2011-05-17 03:18 AM
Hi,
I've been programming with the STM32 for a few weeks now. Right now I have a task which I was hoping to solve with the STM32's SPI. The Task is to Output 25bit Data on an external clock. I configured the SPI1 in slavemode for 8bit Datasize with DMA enabled. The Data is stored in a 4x8bit Array and given to the SPI by DMA. What I would like to do, is to Reset the SPI after 25bits to make it ready for the next 25bits. In other words, I'd like to transmit 3 total Bytes and begin the fourth, but not finish it. I have tried disabling/enabling SPI and DMA, Resetting the SPI Clocks, and overwriting the SPI Data but nothing worked. Is there an opportunity to Reset the SPI so it does not output the last 7bits of the 8bit Data? Cheers, Flo2011-05-17 03:18 AM
Hi again,
I solved the problem. The solution is to enable Hardware NSS Pin Management. You then have two options. BTW, this probably only works in Slave Mode. 1: Configure the NSS PIN in GPIO Mode ''AF_PP'' like in the SPI examples. Now externaly set the NSS PIN LOW before the SPI-CLK and HIGH after your desired amount of Bits. The SPI Shift Register is then cleared and can be reloaded with the new Data. If your application does not use the NSS PIN you can either wire another GPIO Port to it or use option2. 2: Still with the NSS PIN configured in Hardware Mode, instead of setting the corresponding GPIO_PIN in GPIO ''AF_PP'' Mode as before, set it to ''Out_PP''. You now can control the NSS Pin using the GPIO Set and Reset commands and the SPI will react as if the NSS PIN were externaly driven. Although this works fine for now, I'd still like a Software managed NSS PIN Setting better, because my application does not need the NSS Pin and so I could use this Pin for other purposes, so if anybody comes up with a solution please let me know. Cheers, Flo