| Posted: 08:36am 15 May 2018 |
Copy link to clipboard |
 Print this post |
|
As part of incorporating file I/O and more datatypes into my interpreter program I have been able to set up a SD card as an auxiliary drive. It uses a small uno for the drivers/housekeeping, and is driven with single 16-bit spi words to open, read, write, and close bytes and csv file as necessary. This means any four micro pins that can bit-bang some spi can be used to connect it.
eg to write a line of some test variables into a csv file:
PROGRAM testwrite C CHARACTER*20 s INTEGER*1 a INTEGER*4 b, n REAL c DOUBLE d UNSIGNED*1 e a = 123 b = 1222333444 c = 1.123456 d = 1.12345678 e = 234 s = 'squarkoid' OPEN WRITE CALL longd() WRITE (1,*) a, b, c, d, e, s CLOSE END ...
and then read it
PROGRAM testread C CHARACTER*20 s INTEGER*1 a INTEGER*4 b, n REAL c DOUBLE d UNSIGNED*1 e OPEN CALL longd() READ (1,*) a, b, c, d, e, s PRINT a," ",b," ",c," ",d," ",e," ",s CLOSE END ...
displays the line
123 1222333444 1.123456 1.12345678 234 squarkoid
A main advantage is that using a uno means the SD drivers are separately maintainable . Any errors are reported back via the word exchange. On power-up a check is done for directory access etc. I found a small delay was needed between opening a file and accessing it. So far I have run files of 185k without problems, it should be good for 4Gb. It might be useful for other systems, if there is further interest. |