Loading User Data from the SD Card - Data File without Sectors¶
Proceed as follows to read user data from a data file without sectors on the SD Card\ and write them to the CPU:
Insert the SD card.
Read a data set by calling the block SD_READ with the following settings:
EN := TRUE (* FALSE/TRUE edge starts writing *) ATTRIB := 2 (* open / read *) FILENO := 0…99 (* number of the file which is to be read *) SEG := Address of the variable of the sector label (*any*) FORMAT := Data format NVAR := Number of values in data set ADRVAR := Address of the first variable into which data are to be written The read process is successfully completed when output DONE:=TRUE and output ERR:=FALSE. A read error is indicated by ERR:=TRUE and ERNO<>0 Further data sets can be read with the following settings after the completion message is displayed (output DONE=TRUE). This process is started with a FALSE/TRUE edge at input EN:
EN := TRUE (* FALSE/TRUE edge starts reading *) ATTRIB := 3 (* continue read *) FILENO := 0…99 (* number of the file which is to be read*) SEG := Address of the variable of the sector label (*any*) FORMAT := Data format NVAR := Number of values in data set ADRVAR := Address of the first variable into which data are to be written If an unexpected sector label or the end of file (EOF) is detected when reading, a corresponding error message is generated. To read a further data set and to close the file afterwards, call the block SD_READ with the following settings after the completion message (output DONE=TRUE) and start the process with a FALSE/TRUE edge at input EN:
EN := TRUE (* FALSE/TRUE edge starts reading *) ATTRIB := 4 (* read / close *) FILENO := 0…99 (* number of the file which is to be read*) SEG := Address of the variable of the sector label (*any*) FORMAT := Data format NVAR := Number of values in data set ADRVAR := Address of the first variable into which data are to be written If an unexpected sector label or the end of file (EOF) is detected when reading, a corresponding error message is generated. To close the file, call the block SD_READ with the following settings after the completion message (output DONE=TRUE) and start the process with a FALSE/TRUE edge at input EN:
EN := TRUE (* FALSE/TRUE edge starts reading *) ATTRIB := 4 (* close *) FILENO := 0…99 (* number of the file which is to be read*) SEG := Address of the variable of the sector label (*any*) FORMAT := Data format NVAR := Number of values in data set (*any*) ADRVAR := Address of the first variable (*any*)