Posted: Fri Apr 11, 2008 3:21 pm Post subject: Sending large amounts of data to SPI
I am trying to load an external DSP part with code which is stored as data in my Bascom Code. It is 7680 bytes. If I send it all out at once I only need to set up the receiving address once but if I do it in chunks I need to send the new offset address for each chunk making larger bursts much faster. The 255 byte limit becomes a hassle however. This could be overcome by sending 192 bytes x 40 SPIout commands.
While I can send it using an array such as DSPDATA(195) which is 3 bytes of address and 192 bytes of data and repeat 40 times, I am unclear as to how to get the data and the address into the array efficiently. Unless I am missing something this would require a loop of 192 lookup or read functions.
Does the data for an SPIout have to be a single variable or can you put multiple variables in the statment like SPIout A, B, C, 3 ?
If you have the data in a large table (using Data/Read, or stored into program memory) you can use a for/next type loop and send bytes directly to the SPI port without using SpiOut. That way there is no 255 byte limit.
Something like this:
Code:
dim i asbyte dim temp asbyte 'insert code here to write the necessary address/header data to SPI for i =1to NumBytes
read temp
SPDR = temp 'write the byte to the SPI data register bitwait SPSR.SPIF , set'and wait till it has been sent next i
_________________ If all else fails, read the manual. Even better: read the manual before something fails. If you can't find it in the manual, search the forum.
BascomAVR 2.0.8.5
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum