Home
SD-COM User`s Manual
Contents
1. MCU Mode Error Codes baud Error Code Explanation baud Baud rate E00 Command not recognized Operation Set the Baud rate for the serial communications F10 Card not inserted Example Card inserted but not initialized Please E11 baud 9600 remove and re insert the card gt Baudrate 9 600bps E12 Error during Card Initialization Error Code Explanation card E20 File creation Error during fcreate card E21 File Delete Error Operation Retum SD MMC Card Status E22 _ File Rename Error Example When SD MMC Card Inserted E ee eee San E31 rd command Error gt SD MMC card inserted E32 od command Error E40 fsize command Error Example When SD MMC Card Removed E41 ftime command Error card E50 fopen command Error gt Error SD MMC card NOT inserted E51 fopen command Eror E52 fopen command Error When SD MMC Card is Removed and Re inserted the following E53 fopen command Error message will appear E54 File open already E55 fclose command Error Stemma vee E56 Command not available during fopen gt SD MMC card inserting E5 fopen must be used beforehand gt SD MMC card detected E58 During fopen command only options r w a may be used E60 fgetc option not between 1 and 256 bytes lt MCU Mode gt E61 Fgetc command my only use option Ir an E70 ia command may only use
2. SD MMC COMB5 or 3V SD MMC COM3 level 5 10 reserved Reserved for future I O ports 19 RXD How to connect data lines for Firmware Upgrade Do not connect TXD RXD directly to PC s serial port as PC uses 12V RS232 levels You need to use a MAX232 chip to convert 5V TTL to 12V RS232C level before doing so 5 How to connect data lines m Processor Connection CUBLOC etc You can check the status of SD MMC card insertion by connecting SDIN pin to one of your processor s input pins Comfile Technology Inc SD MMC User Manual page 2 www comfiletech com 888 9CUBLOC Fax 650 638 1360 COMPILE TECHNOLOGY 4 2 6 Communication Protocol m Basics Command Filename Option Data Command Filename Option and data are separated by a space HEX 0x20 Depending on the command Filename Option and Data can be required All Commands must be followed by a CR Carriage Return 0x0D and LF Line Feed Ox0A For example to store Hello World into text txt you would do InC printf fputs test txt Aw Hello World r n In CUBLOC Putstr 1 fouts test txt Aw Hellow World cr lf m Retum Values The SD MMC COM will reply as follows lt Message gt Normal When command is processed successfully the SD MMC COM will return a capitalized O or in hex Ox4F Error When command is not processed successfully an error will occur and the SD MM
3. 9600 bps 0 4KB s 9600 bps 0 8kB s Warning The SD MMC card comes in FAT16 as factory default Please do not re format the SD MMC card in FAT32 Please format the SD MMC card as FAT16 for SD MMC cards in FAT32 before using Please do not eject SD MMC card during read write operations This can cause loss error to your files Depending on the SD MMC Card model read write speed may differ slightly SD MMC card is slightly different from the CF card because 5V cannot be used directly to it The SD COM5 contains a 3 3V regulator and a logic level converter 4 Dimensions m Front TR hp iii iii i i rl jal iii a ft T i T SL H ae a 1 i Ea ol SD COM3 SD COM5 SD MMC User Manual page COMFILE amp Serial SD MMC Card Module User Manual S D M M C TECHNOLOGY 42 m How to connect SD MMCIN pin to an LED m Pin Specification Pin Name Description 1 SOUT Serial Output pin for Firmware Upgrade 2 SIN Serial Input pin for Firmware Upgrade 3 18 GND GROUND Firmware Upgrade Status Pin 4 DNLD During Firmware Upgrade LOW Normal HIGH 15 RST RESET Pull up with 10K resistor 16 VCC Power 5V 4 5 5 5V 3V 2 7 5 5V SD MMC Card Detection You will be able to see the LED light up when the SD MMC card 17 SDIN SD MMC Inserted LOW inserted SD MMC Not Inserted HIGH TTL Input pin for 5V SD MMC COMS or 3V SD MMC COMS level 50 TXD TTL Output pin for 5V
4. C COM will return a capitalized E or in hex 0x45 lt Data gt When reading a file the SD MMC COM will return the data after the message m MCU Mode and Terminal Mode lt MCU Mode gt is used when you are connecting SD MMC COM to another control device such as CUBLOC The factory default is set to MCU Mode lt Terminal Mode gt is used when you are connecting SD MMC COM to PC s Hyperterminal or similar program for testing and debugging The retumed messages are in a more Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 Serial SD MMC Card Module User Manual SD MMC detailed format lt MCU Mode retum Message in Hyperterminal gt t CF COM AiR Ter Bee BAM FHL ae Sew O a 5 Ds Ff fopen tesc cee sr a Sm Ne ANSI Sul ST lt Terminal Mode retum Message gt CF COM 0mEn a TRE MAE SA0 ERIC eT cash D oe a O04 m fopen E SCL 0C 0C FE File cpeni EAD oe i Si titi ANSI apii A 1 Commands For Terminal Mode mode mode Option Operation Select MCU Mode or Terminal Mode Option It Terminal Mode Im MCU Mode Example mode t gt Mode terminal full message mode m gt Mode MCU simple message init SD MMC User Manual page 3 COMFILE i Serial SD MMC Card Module User Manual S D M M C TECHNOLOGY 4 2 init init fsize Operation Initialize the SD MMC Card fsize Filename Exampl
5. COMFILE TECHNOLOGY Serial Serial SD MMC Card Module User Manual SD MMC UBLOC Peripheral SD MMC Serial SD MMC Card Module User Manual i T COMF ILE 1 Intro The Seral SD MMC Card Module allows the user to read SD MMC cards using TTL level serial communication You will be able to interface with CUBLOC CuTOUCH or any other control devices that supports TTL serial 2 Features Simple commands through TTL serial communication for creating files writing and reading data Industrial Standard FAT 16 supported FAT32 is not supported Up to 2Gigabytes of SD MMC Card supported Read Write Text and Binary data Korean Language supported Terminal Mode for using with MCUs or PC s Hyperterminal Automatic Card detection Status pins for Card detection 2 Wire RX and TX for 5V or 3V RS232C No parity 8bit Data 1 stop bit Set baud rates using commands Baud rates supported bps 4800 9600 19200 38400 57600 115200 Default 9600bps Current Consumption SD COM5 5V 30mA Idle SD COM3 3V 9mA Idle Read Write Operation Add 30mA Firmware Upgrade through Intemet Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 3 Specifications Model SD COM5 SD COM3 Voltage 4 5 5 9V 2 0 0 115200 bps 10KB s 115200 bps 8KB s Read Speed 9600 bps 8KB s 9600 bps 2KB s 115200 bps 8KB s 115200 bps 2KB s Write Speed
6. EAD OK 456789 gt Packet 6 bytes write OK fgets fclose This is SD MMC COM gt File close OK igets Testing fgets Command fgets B testext Hiss DBE Comfile Technology Umie Fie Mes SS Sel fclose HIS daoe rey gt File close OK fopen command must be used before using fgets command fopen command must be used before using fwrite command fread fgetc fread Filename fgetc of bytes to read Operation Read all data in File Operation Read up to set of bytes Up to 256 bytes per Example Operation fputs test txt Av This is SD MMC COM Example gt Put string OK fouts test txt Ww 0123456789 fouts test txt a Testing fread Command gt Put string OK gt Put string OK fopen test txt r fputs test txt a Comfile Technology gt File open READ OK gt Put string OK fgetc 4 fread test txt 0123 This is SD MMC COM fgetc 6 Testing fread Command 456789 Comfile Technology fclose gt File close OK fopen command must be used before using fgetc command www comfiletech com 888 9CUBLOC Fax 650 638 1360 COMFILE i Serial SD MMC Card Module User Manual S D M M C TECHNOLOGY 4 2 reset MCU Mode returns O Ox4F for successful operations except reset when SD MMC Card is Inserted where a I and a D is returned Operation SD MMC COM EALE JA AJYA Example help reset help gt System reset OK Operation Show Help Menu m Error Message
7. GY 4 2 This product does not have a real time clock therefore when doing a file write the Creation and Last Modified times are not recorded Only files created or modified in the PC will show Creation and Last Modified times md md Directory Operation Make Directory Example md mydir1 gt Make directory OK md mydir1 sub1 gt Make directory OK rd rd Directory Operation Remove Directory Example rd mydir1 gt Remove directory OK rd mydir1 sub1 gt Remove directory OK Please remove the files within the directory before removing This command only will remove empty directories del del Filename Operation Delete File Example del test txt gt Delete file OK del mydir1 test txt gt Delete file OK Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 Serial SD MMC Card Module User Manual SD MMC fcreate fcreate Filename Operation Create a new file with size 0 Example fcreate test txt gt File create OK fcreate mydir1 test txt gt File create OK fcreate command will create a file with size 0 Therefore all read write commands with options Open File r or Append File la cannot be used rename rename Source Filename Destination Filename Operation File2 S S By Hg Example test xt FileS test2 dat Z 5 O 477 rename test txt test2 dat gt Rename OK
8. Put string OK fputs test txt a Comfile Technology gt Put string OK P test txt H o IAD Gare AMANO BV Seay This is CF COM Testing fputs Command Comfile Technology fouts2 fputs2 Operation Write until Z Ctrl Z ASCII Code 0x1A is received Up to 256 bytes or characters may be written Example fopen test txt Aw gt File open WRITE OK fouts2 gt File put string ready This is SD MMC COM gt Put string OK continue or Z Testing fouts2 Command gt fputs2 end P test tst H22 IEE GEE AAC SA00 SSB This is CF COH Testing fputs Command fopen command must be used before using fputs2 command lt Ctrl Z gt will automatically close the file and fclose command does not have to be called SD MMC User Manual page 6 COMFILE amp Serial SD MMC Card Module User Manual S D M M C TECHNOLOGY 4 2 fgets fwite fgets fwrite of bytes to write Operation Read 1 line of string new line Operation Write up to set of bytes Up to 512 bytes per Operation Example Example fputs test txt w This is SD MMC COM fopen test txt Aw gt Put string OK gt File open WRITE OK fputs test txt a Testing fgets Command fwrite 4 gt Put string OK gt Packet size 4 bytes 0123 gt Packet 4 bytes write OK fputs test txt a Comfile Technology gt Put string OK fwrite 6 fopen test txt r gt Packet size 6 bytes gt File open R
9. d_end 0 unsigned int RX_count 0 void init void WDTCR 0x00 asm cli Watchdog Timer disable global interrupts disable UCSROB 0x00 UCSROA 0x00 9 600bps UCSROC 0x06 UBRROH 0x00 UBRROL 0x5F UCSROB 0x98 I Set UARTO to 9 600bps II SD MMC COM must be also set to PORTB 0x00 DDRB 0x10 Set PB4 as PWM Timer Counter 0 initialization Il OCO output Non Inverted PWM ASSR 0x00 TCCRO 0x67 TCNTO 0x00 OCRO 0x00 asm sel global interrupts enable void main void unsigned int i init Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 Serial SD MMC Card Module User Manual SD MMC printf fread sine dat r n Read File while 1 if fread_end 1 OCRO RX_buffii delay_ms 20 i if RX_count i 0 Y end if Y end while MMM i UARTO receive interrupt service routine MMM interrupt USARTO_RXC void usart0 _rx_isr void unsigned char status data II OutputPWM data UDRO Store Sine Wave values from SD MMC COM in a buffer RX_buff RX_count data RX_count if RX_count gt 208 fread_end 1 8 Example 2 Read Temperature Sensor and store current temperature values in a File of SD MMC Card m Circuit Schematics HH 14 7456 MHz 20pF L 20pF SD MMC User Manual page 10 COMFILE fe TECHNOLOGY Connect the SD MMC COM and the processor Connect the voltage output for temperature of LM35 to th
10. e Operation Display File size Retum Value File Size init Example Terminal Mode gt Initialize OK fsize test txt gt File Size 7618 bytes Example MCU Mode cd fsize test txt cd Change Directory 7618 Operation Change directory Directory name must be within 40 characters Example 1 Change directory to mydir sub dsize cd mydir sub dsize gt Change directory OK mydir1 sub1 Operation Display Total Disk Space of the SD MMC Card Return Value Total Disk Space of SD MMC Card Example Terminal Mode Example 2 Change directory to root directory cd dsize gt Change directory OK gt Total size 128032768 bytes 125 MB Example MCU Mode dir dsize dir 128032768 Operation List Directory Return Value Filenames are retumed with size of file inside Directory names are retum with brackets fime i i Eae ftime Filename L dir Operation Display File creation and Last Modified times ROOT Retum Value File creation and Last modified times SINE DAT 210 Example Terminal Mode TEST TXT 7618 fsize test txt MYDIR1 gt File created 08 01 2005 15 37 13 MYDIR2 File modified 07 21 2005 11 10 08 Example MCU Mode ftime test txt 08 01 2005 15 37 13 07 21 2005 11 10 08 Comfile Technology Inc SD MMC User Manual page 4 www comfiletech com 888 9CUBLOC Fax 650 638 1360 COMPILE TECHNOLO
11. e ADC of the processor LM35 output 0 01V per 1C For example when LM35 voltage output is 0 26V this means the current temperature is 26C m How to When the source code in the processor is executed thermo1 txt and thermo1 dat files are created in the SD MMC card Every 1 second the Temperature is converted and stored in themo1 txt as text and thermo2 dat as binary values After a few seconds of execution you may open thermo txt file in PC and verify the written data You can also verify the binary data using programs such as UltraEdit lt thermo1 txt gt P testixt HT IEE GEE MAD BM Taek z 28 degrees z 29 degrees 30 degrees 38 degrees 30 degrees 32 degrees lt Binary File thermo dat gt OOO00RO0h Jc 54 45 4 50 5E Ob OA iC i i ib ib ib 1E i OOO0OOL0n JE LE 1E iE UF iF iF iF iF iF iF iF 1 iE iE iE QOO00Ge Oh 1D iB 1b 1D if 14 1D Ge it 1 ic itt 1 1p 1C oie m Source Code Poe a eee eaten ee en nee ere Project Example 2 Compiler CodeVisionAVR Chip type ATmega64 Clock frequency 14 745600 MHz Data Stack size 1024 S E E EE E include lt mega64 h gt include lt delay h gt include lt stdio h gt Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 Serial SD MMC Card Module User Manual SD MMC define ADC_VREF_ TYPE OxC0O AVREF intemal 2 56V char fRX 0 LL III Read the AD conversion result Me unsigned int read_adc
12. fopen fopen Filename Option Operation Open File Option lr File Read lw File Write la File Append Example File Read fopen test txt r gt File open READ OK Example File Overwrite fopen test txt Aw gt File open WRITE OK Example File Append fopen test txt a gt File open APPEND OK After opening a File you must use File Close fclose command to Close the File Only 1 File may be opened at one time r and a Option cannot be used with Files of size 0 SD MMC User Manual page 5 COMPILE Serial SD MMC Card Module User Manual TECHNOLOGY fclose fclose Operation Close File Example fopen test txt r gt File open OPEN OK fclose gt File close OK foutc fputc Filename Option 1 Byte Data Operation Write 1 byte to the File Option lw File Write la File Append Example foutc test txt Aw A gt Put character OK foutc test txt a B gt Put character OK foutc test txt a C gt Put character OK E stis WS TRE EAH MA SOI TELH fputs fputs Filename Option String Operation Write up to 256 cha racters of String data to the File Option lw File Write la File Append Example Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 SD MMC fouts test txt Aw This is SD MMC COM gt Put string OK fouts test txt a Testing fouts Command gt
13. gdddd 0k CT CB Cai Ca a ES CS cr CT C7 Ch CS CS Ca C3 C2 QOO0OD4GR Ci CO BF BD BC BA EP BY BS B4 Be BO AE AC AA AG QOOO0OS0h AS AJ Al SE JG oo OF D4 91 GF Ge 39 Ge 64 Gi TE QOOO0OGOh TE Th 75 72 GF G 69 66 63 60 5D Sa ST 54 51 4E jjj h 46 49 46 45 40 3b 34 36 35 32 30 2h 2B 2b 26 24 DOQUOMSOGR 21 iF 10 18 19 17 15 13 12 10 OF OF OF OL 09 OB QO0000CSOh D 05 0S 04 03 G2 Oz D1 01 00 00 OO OO OD OO OO OO000Gea0h OF 01 OF Of 03 04 04 DS OS OF 09 OA OE OD OE 10 OO000OROH 11 13 15 17 19 LE 1D LF 21 23 6 23 ZA 2D 4f 92 QOO0OOCOh 35 97 FA 3D 40 42 45 46 45 4E 51 54 57 SA SB 60 OOOQOFOh 63 86 When the source code in the processor is executed the sine dat File from SD MMC card is read and outputted as PWM signal At this time the PWM output is set as an RC filter causing the digital signal to be outputted as analog signal The RC filter acts as a generic DAC digital to analog converter Depending on the data stored in the SD MMC Card the user is able to output various waves or even ECG signals allowing it to act lt Output Wave gt Tek BEA 50 Sis Acs i SD MMC User Manual page 9 COMFILE fe TECHNOLOGY m Source Code I Fe er E E ae ene ae nates n ne maT Project Example 1 Compiler CodeVisionAVR Chip type ATmega64 Clock frequency 14 745600 MHz Data Stack size 1024 a a a a include lt mega64 h gt include lt delay h gt include lt stdio h gt unsigned char RX_bufff210 unsigned char frea
14. nology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 Serial SD MMC Card Module User Manual SD MMC Write to binary file using fputc printf foutc thermo dat a Yoc r n unsigned char temper wait_message delay _ms 1000 Delay 1 second Y end while MMM UARTO receive interrupt service routine MMM interrupt USARTO_RXC void usartO_rx_isr void unsigned char status data status UCSROA data UDRO if data 0 OK reply ASCII Code 0x4F fRX 1 9 Dimensions Units mm Bos Sale 3s SD MMC User Manual page 12 COMFILE i Serial SD MMC Card Module User Manual S D M M C TECHNOLOGY 4 2 Max s How to using CUBLOC Study Board right from the package 1 Connect 5V and GND of the SD Card Module to 5V and GND of the study board 2 Connect TXD and RXD of the SD Card Module to RX and TX pin of CB280 on the upper right corer on the Study board For CB280 connect to P10 and P11 3 Connect your PC s serial cable to the bottom serial port of the study board 4 Nowyou are ready to communicate to the SD Card 5 Run the Code you can download at www cubloc com under Max s Application Download under the title Max s CF SD Card Library Comfile Technology Inc SD MMC User Manual page 13 www comfiletech com 888 9CUBLOC Fax 650 638 1360
15. options w or ID E71 Data Write error during fputc fputs command only options w or a may be E72 used Comfile Technology Inc SD MMC User Manual page 8 www comfiletech com 888 9CUBLOC Fax 650 638 1360 COMFILE TECHNOLOGY Serial SD MMC Card Module User Manual SD MMC E73 fputs command Error E74 fwrite option must be between 1 and 512 bytes E80 baud rate setting Error lt MCU Mode Error Message gt eH Bole SIE SY SRC As Seen fopen East dat T ES ANSI 600 8 M 1 lt Terminal Mode Error Message gt CF COM Hlne Cae as 08 amp fopen test dae FE Erros Cile open S itr ANSI 9600 3 N 1 7 Example 1 Read Sine Frequency File from the SD MMC card and output as analog signal m Circuit Schematics ATmegabd RAD Please connect the SD MMC COM and the processor and set the Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 processor s PWM to output and create an RC filter m How to Using your PC store sine dat File in the SD MMC card This File is a binary File that stores a sine wave such as shown below Se 0 ia ida anf a i ii Se a Be Bi Th ka BT 1G iZi ie ide ia PE g Soe lt sine dat File 210 bytes of data gt DOQ000DOR Gr SA 60D 70 732 Fe 79 To TF G2 84 OF SA BO BF Ge QOO0001OGR 955 57 9A JC SF Al AD 16 LE AA AC AE BO Ez E H5 OOO00GL2Oh BE BS BH HC HE EF CO Cl ci cS C4 CS Ce CE CT cr g
16. unsigned char adc_input unsigned long data 0 ADMUX adc_input ADC_VREF_TYPE ADCSRA 0x40 Start AD Conversion while ADCSRA amp 0x10 0 Wait until finished ADCSRA 0x10 data ADCW retum data void init void WDTCR 0x00 Disable Watchdog asm cli global interrupts disable UCSROB 0x00 UCSROA 0x00 9 600bps UCSROC 0x06 UBRROH 0x00 UBRROL Ox5F UCSROB 0x98 II Set UARTO to 9 600bps I SD MMC COM must also be set to ADC initialization II ADC Clock frequency 115 200 kHz II ADC Voltage Reference Int cap on AREF ADMUX ADC_VREF_TYPE ADCSRA 0x87 asm sel global interrupts enable SD MMC User Manual page 11 COMFILE TECHNOLOGY void wait_message void II Wait reply from SD MMC COM while fRX 0 fRX 0 void main void unsigned int a 0 unsigned int temper 0 init Create File printi fcreate thermo txt r n wait_message Create File printf fcreate thermo datirin wait_message while 1 After using fcreate you may use option a after writing to it using option Aw printf fouts thermo txt Aw lt Temperature Example gt rin wait_message printf fputs thermo1 dat Aw lt TEMP gt rin wait_message while 1 a temper read _adc 0V1024 0 2 56 100 II Nrite to text file using fputs printf fputs thermo1 txt a Data d Temp d C n a temper wait_message Comfile Tech
Download Pdf Manuals
Related Search
Related Contents
NOTICE 38001027 RG 9 Ver oct 2011 Au lieu que je déclaire, Le fleuve Lot coule son eau peu claire, Qui Octobre - Corporation des Maîtres Électriciens du Québec Switch On Kaffeemaschine Bedienungsanleitung CNC 800M -USER - (fre) Global Map Raster Devel- opment (GMRD) Tool User`s Manual Philips HX9170/10 Data Sheet Mode d`emploi SC 18 170 410 μ830 取扱説明書 Copyright © All rights reserved.
Failed to retrieve file