Atmega16 SPI to clock out 32bit data

atmegaspi

I am very new to AVR and even for coding of micro-controllers. I wanted to shift out 32 bit data on SPI from a Atmega16 to a 32 bit shift register. The shift register in not an SPI compatible device. But still hope to use to get the fast transmission.

Since the AVR is having only 8 bit data register, only one byte of data can be written on it. So I need to shift our 32 bits of data. I am able to do the same like making SS# low->load first byte of data->wait till transmission complete->make SS# to high to latch the data. I am doing it four 4 times and getting the 32 bit output. But the issue here is the clock is not continuous, for each byte there is a delay between the clock burst. In this this case the external shift register will not get the 32 bit continuously since for every byte I am doing the SS# low and high. I need to get the complete data packet continuously with out any break. I am digging further into this to resolve.

It would be helpful for me in the meantime if someone can share any idea.

Regards,
Prabhu

Best Answer

Continuous transactions longer than 8 bits are not possible on ATMega16. You have to poll for SPIF and then load new value. On other MCUs that have double buffered data register, it is possible to reload the data register before it is emptied.

There is no need to assert SS# between words. From SPI's static point of view, in modes 1 or 3, sending 8*4 bits is equivalent to sending 1*32 bits even when it happens seconds apart.