I am writing 72,000 characters to U0: with L command (SPI). I am monitoring MOSI and MISO lines to ALFAT
It looks like everything is transferred to ALFAT correctly. I send J command, I command, E command, K command, open file (TREK009.txt). Alfat responds correctly (no errors) for each command.
Send L command (“L 0>11940\r”)
Alfat responds - !00
I then send 72,000 characters (every 6 characters is 1 piece of data (in volts)
Then 0x02, 0x0E, 0x00
Alfat responds - $00011940 !00
Send close command
Alfat responds - !00
However, the file that is created on the USB drive (TREK009.txt) does not contain all the data. Only 9,948 out of 72,000. And not all of the 9,948 are correct.
If all the data is sent to ALFAT correctly, what needs to be done for ALFAT to send information to U0 correctly?
it doesn’t matter if W command, but for L command, it requires about 20ms to send whole block 8KB, it means at least 3.3MHz SPI clock master. So 400K is too low.
And L command requires block 8KB, you can not send few bytes then delay a bit then send few bytes again!
Of course the last block doesn’t need 8KB!
We tested at 3MHz it works fine but following that, better if it is 4Mhz or higher!
It looks like I will not be able to use the L command because my data is in blocks of 6bytes and 8K does not divide evenly by 6.
I have also been trying to use the W command, but also cannot get it to work. Is there a size constraint for the W command? Can I write 72,000 bytes by sending 4 frames with a payload of 18,000 each?
With the W command I see the SPI busy signal go high after writing only a small amount of data.
“Block is 8KB, except for last block”, if you have 6KB, so the first block is also the last block, so 6KB will be fine.
Is there a size constraint for the W command
W command, there is 0xFFFFFFFF, about 4GB and this is also max of FAT32 for length of a file.
For SPI frame, there is 0xFFFF, means about 65KB, so 72000 bytes will be 2 frames
W command is ALFAT command, it is same for all SPI, I2C, UART
SPI frame is only for SPI, it is separated.
With the W command I see the SPI busy signal go high after writing only a small amount of data.
Don’t worry, just continue sending data when it goes low. This is high when the buffer is full or busy for something.
when it is high => stop sending, when it is low => continue sending,
In W command, you should send one byte one, delay time between 2 bytes is 4us at 24Mhz.This is important or data will be lost. If using L command, no delay needed.