Home

Serial Compact Flash

image

Contents

1. Error Code Explanation card E20 File creation Error during fcreate card E21 File Delete Error Operation Return CF Card Status E22 _File Rename Error Example When CF Card Inserted me eae card E31 rd command Error gt CF card inserted E32 cd command Error E40 fsize command Error Example When CF Card Removed E41 ftime command Error card E50 fopen command Error gt Error CF card NOT inserted E51 fopen command Eror E52 fopen command Error When CF Card is Removed and Re inserted the following E53 fopen command Error message will appear E54 File open already E55 fclose command Error lt Terminal Mode gt E56 Command not available during fopen card gt CF card inserting E57 fopen must be used beforehand gt CF 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 r e a E mO Se PoS Ma la ID E71 Data Write error during fputc Diromg fputs command only options w or a may be used E 2 Comfile Technology Inc CF User Manual page 8 www comfiletech com 888 9CUBLOC Fax 650 638 1360 COMPFILE Serial CF Card Module User Manual CF TECHNOLOGY 42 E73 fputs command Error processor s PWM to output and create an RC filter E74 fwrite option must be between 1 and 512 bytes E80 baud rate setting Err
2. 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 CF User Manual page 5 COMFILE Serial CF Card Module User Manual C F TECHNOLOGY P testtxt HID fdose TF B MAO HII TS fclose l This is CF COH _ nn Testing fputs Command Operation Close File Comfile Technology Example fopen test txt r gt File open OPEN OK fclose gt File close OK fouts2 puig fputs2 fputc Filename Option 1 Byte Data l l Operation Write until Z Ctr Z ASCII Code 0x1A is received Operation Write 1 byte to the File Up to 256 bytes or characters may be written Option Iw File Write Bane mm Ele nppele fopen test txt Aw gt File open WRITE OK Example ole str d EXAMP amp lan pre e ae Tiss CFCOM gt Put ct j ule mere an gt Put string OK continue or Z gt Put character OK Testing fputs2 Command foutc test txt a C gt fputs2 end gt Put character OK E testint WS i z At TRIE EAE Mag Oy TETH B testera were BEE ISD H amp E MAD EY SS StH This is CF COH Testing fputs Command fouts fputs Filename Option String Operation Write up to 256 characters of String data to the File Option Aw File Write does not have to be called la File Append Example fouts test txt Aw This is CF COM gt
3. 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 CF Card Module User Manual CF printf fread sine datir 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 MMMM i UARTO receive interrupt service routine MMM interrupt USARTO_RXC void usartO_rx_isr void unsigned char status data OutputP WM data UDRO Store Sine Wave values from CF 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 CF Card m Circuit Schematics ATmegab4 CF User Manual page 10 COMFILE TECHNOLOGY Connect the CF COM and the processor Connect the voltage output for temperature of LM35 to the ADC of the processor LM35 output 0 01V per 1 For example when LM35 voltage output is 0 26V this means the current temperature is 26 C m How to When the source code in the processor is executed thermo ixt and thermo1 dat files are created in the CF 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 thermo1 txt file in PC and verify the written data You can also veri
4. 650 638 1360
5. Put string OK fputs test txt a Testing fouts Command gt Put string OK fputs test txt a Comfile Technology gt Put string OK fopen command must be used before using fputs2 command lt Ctrl Z gt will automatically close the file and fclose command Comfile Technology Inc CF User Manual page 6 www comfiletech com 888 9CUBLOC Fax 650 638 1360 COMPILE TECHNOLOGY 42 fwrite fwrite of bytes to write Operation Write up to set of bytes Up to 512 bytes per Operation Example fopen test txt Aw gt File open WRITE OK fwrite 4 gt Packet size 4 bytes 0123 gt Packet 4 bytes write OK fwrite 6 gt Packet size 6 bytes 456789 gt Packet 6 bytes write OK fclose gt File close OK E testixt Alsat ORF BSE daig SS SH DA FaaSo7rey fopen command must be used before using fwrite command fgetc fgetc of bytes to read Operation Read up to set of bytes Up to 256 bytes per Operation Example fouts test txt Aw 0123456789 gt Put string OK fopen test txt r gt File open READ OK fgetc 4 0123 fgetc 6 456789 fclose gt File close OK fopen command must be used before using fgetc command Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 Serial CF Card Module User Manual CF fgets fgets Operation Read 1 line of string new line Example fouts test txt Aw This is CF COM g
6. B s Warning The CF card comes in FAT16 as factory default Please do not re format the CF card in FAT32 Please format the CF card as FAT16 for CF cards in FAT32 before using Please do not eject CF card during read write operations This can cause loss error to your files LEXAR media s CF Cards have less compatibility we recommend to SanDisk Depending on the CF Card model read write speed may differ slightly 4 Dimensions m Front COHETE z 7 ai mtm ze imi Wa smi m Back EHE SiL ferch cO A 572 i ua iG TR ra a one wink 1 CF User Manual page COMFILE Serial CF Card Module User Manual C F TECHNOLOGY 4 m How to connect CFIN pin to an LED m Pin Specification Pin Name Description 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 Pullup with 10K resistor 16 VCC Power 5V 4 5 5 5V 3V 2 7 55V peru You will be able to see the LED light up when the CF card in 17 CFIN CF Inserted LOW CF Not Inserted HIGH inserted 19 RXD RS232C Input pin for 5V CF COMS or 3V CF COMS level How to connect data lines for Firmware Upgrade 20 TXD RS232C Output pin for 5V CF COM5 or 3V CF COM3 level 5 10 reserved Reserved for future I O ports Do not connect TXD RXD directl
7. COMPILE TECHNOLOGY 4 Serial CF Card Module User Manual CF CUBLOC Peripheral Serial Compact Flasn Serial CF Card Module User Manual CompactFlash 1 Intro The Serial CF Card Module allows the user to read Compact Flash cards using RS232C serial communication You will be able to interface with CUBLOC CuTOUCH or any other control device that supports RS232C 2 Features Simple commands through RS232C communication for creating files writing and reading data Industrial Standard FAT 16 supported FAT32 is not supported Up to 2Gigabytes of CF 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 Current Consumption CF COM5 5V 25mA Idle CF COMS3 3V 7mA Idle Read Write Operation Add 40mA Firmware Upgrade through Intemet Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 3 Specifications Model CF COM5 CF COM3 Voltage 4 5 5 9V Zl O 0V 115200 bps 20KB s 115200 bps 15KB s Read Speed 9600 bps 6KB s 9600 bps 5KB s 115200 bps 5KB s 115200 bps 4KB s Write Speed 9600 bps 0 8KB s 9600 bps 0 5k
8. MCU Mode gt is used when you are connecting CF 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 CF COM to PC s Hyperterminal or similar program for testing and debugging The returned messages are in a more detailed format Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 lt MCU Mode retum Message in Hyperterminal gt r CF COM stoleiois le DBF BSE SM SRC Bell Saw O a 3 n g fopen test cee JT lt Terminal Mode retum Message gt e CF 00M aE OS TRE BENE SAW Sei Bet Samah Oe sg D9 F TORE CSL CNC FE Pile openiREAD oF i Sim trite AHS S600 3 H 1 Commands For Terminal Mode mode mode Option Operation Select MCU Mode or Terminal Mode Option t Terminal Mode m MCU Mode Example mode t gt Mode terminal full message mode m gt Mode MCU simple message init CF User Manual page 3 COMFILE Serial CF Card Module User Manual C F TECHNOLOGY 42 init init fsize Operation Initialize the CF Card fsize Filename Example 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 E
9. 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 92 45 46 45 4E 51 54 57 SA SB 60 OOOQOFOK 63 86 When the source code in the processor is executed the sine dat File from CF 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 CF 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 ans i CF User Manual page 9 COMFILE TECHNOLOGY m Source Code E E NERO ae eC Ren Project Example 1 Compiler CodeVisionAVR Chip type ATmega64 Clock frequency 14 745600 MHz Data Stack size 1024 i a a include lt mega64 h gt include lt delay h gt include lt stdio h gt unsigned char RX_bufff210 unsigned char fread_end 0 unsigned int RX_count 0 void init void WDTCR 0x00 asm cli Watchdog Timer disable global interrupts disable UCSROB 0x00 UCSROA 0x00 UCSROC 0x06 UBRROH 0x00 UBRROL 0x5F UCSROB 0x98 II Set UARTO to 9 600bps CF COM must be also set to 9 600bps PORTB 0x00 DDRB 0x10 Set PB4 as PWM I Timer Counter 0 initialization Il OCO output Non Inverted PWM ASSR 0x00 TCCRO 0x67 TCNTO 0x00 OCRO 0x00
10. fy the binary data using programs such as UltraEdit lt thermo1 txt gt P test tst Mae ese MAOI BA Tagh Temp 28 degrees Temp 29 degrees Temp 38 degrees Temp 38 degrees Temp 38 degrees Temp 32 degrees lt Binary File thermo dat gt OOO00RO0h Je 54 45 4 50 5E Ob OA iC i 1 ib ib ib 1E i OO000020h TE LE 1E 1E iF iF iF iF iF iF iF iF iE 1E 1E 1 OQOO00GR2 Oh aD if 1b 1D i0 14 1D 2e it 1 ic itt 1 1p 1C oie m Source Code nA Neen eR ner a eg Project Example 2 Compiler CodeVisionAVR Chip type ATmega64 Clock frequency 14 745600 MHz Data Stack size 1024 A E E age nage include lt mega64 h gt include lt delay h gt include lt stdio h gt define ADC_VREF_TYPE OxCO AVREF internal 2 56V Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 Serial CF Card Module User Manual CF char fRX 0 Le III Read the AD conversion result ee unsigned int read_adc 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 UCSROC 0x06 UBRROH 0x00 UBRROL 0x5F UCSROB 0x98 II Set UARTO to 9 600bps II CF COM must also be set to 9 600bps ADC initializat
11. ion II ADC Clock frequency 115 200 kHz II ADC Voltage Reference Int cap on AREF ADMUX ADC_VREF_TYPE ADCSRA 0x87 asm sel void wait_message void Wait reply from CF COM global interrupts enable CF User Manual page 11 COMFILE Serial CF Card Module User Manual C F TECHNOLOGY 42 while fRX 0 fRX 0 delay_ms 1000 Delay 1 second V end while void main void fo IIIA wl n n i UARTO receive interrupt service routine a ala PIII LALIT interrupt USARTO_RXC void usartO_rx_isr void unsigned char status data init II Create File printf fcreate thermo txt r n wait_message status UCSROA data UDRO Create File printf fcreate thermo1 dat r n if data O OK reply ASCII Code 0x4F wait_message fRX 1 while 1 After using fcreate you may use option a after writing to it using option w printf fouts thermo txt Aw lt Temperature Example gt rin wait_message 9 Dimensions Units mm printf fputs thermo dat Av lt TEMP gt rin wait_message while 1 att temper read_adc 0 1024 0 2 56 100 Write to text file using fouts printf fouts thermo1 txt a Data d Temp d C rin a temper wait_message Write to binary file using fputc printf foutc thermo dat a Yoc r n unsigned char temper wait_message Comfile Technology Inc CF User Manual page 12 www comfiletech com 888 9CUBLOC Fax
12. or a How to Using your PC store sine dat File in the CF card This File is a binary File that stores a sine wave such as shown below lt MCU Mode Error Message gt FHA oS ABE S700 SRC Asi SALH fopen East dat Jr ES ANSI 600 8 M 1 lt Terminal Mode Error Message gt et REE BAY SBC Beit CEH S35 wb P TAP D g AELE fopen test dakt FE 2EP roe File open Ae ati 0 ANSI S600 amp h 7 Example 1 Read Sine Frequency File from the CF card and output as analog signal m Circuit Schematics Please connect the CF COM and the processor and set the ATmeqaba RADO fe TADO Comfile Technology Inc www comfiletech com 888 9CUBLOC Fax 650 638 1360 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 7 SA 6D 70 73 Fe 79 To TF G2 84 OF BA BO OF Ge QOO0001GR 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 ggdddd 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
13. ry OK md mydir1 sub1 gt Make directory OK rd rd Directory Operation Remove Directory Example rd mydir1 gt Remove directory OK rd mydir1 sub 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 CF Card Module User Manual CF fcreate md 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 Example test xt FileS test2 dat 5 O 477 rename test txt test2 dat gt Rename OK fopen fopen Filename Option Operation Open File Option r 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
14. t Put string OK fouts test txt a Testing fgets Command gt Put string OK fputs test txt a Comfile Technology gt Put string OK fopen test txt r gt File open READ OK fgets This is CF COM fgets Testing fgets Command fgets Comfile Technology fclose gt File close OK fopen command must be used before using fgets command fread fread Filename Operation Read all data in File Example fouts test txt Aw This is CF COM gt Put string OK fouts test txt a Testing fread Command gt Put string OK fputs test txt a Comfile Technology gt Put string OK fread test txt This is CF COM Testing fread Command Comfile Technology CF User Manual page 7 COMFILE Serial CF Card Module User Manual C F TECHNOLOGY 2 reset MCU Mode returns O Ox4F for successful operations except reset when CF Card is Inserted where a I and a D is retumed Operation CF COM SEALE JA AJAH Example help reset help gt System reset OK Operation Show Help Menu m Error Message MCU Mode Error Codes baud Error Code Explanation baud Baud rate E00 Command not recognized Operation Set the Baud rate for the serial communications E10 Card not inserted Example E11 Card inserted but not initialized Please baud 9600 remove and re insert the card gt Baudrate 9 600bps E12 Error during Card Initialization
15. xample 1 Change directory to mydir sub dsize cd mydir sub1 dsize gt Change directory OK mydir1 sub1 Operation Display Total Disk Space of the CF Card Retum Value Total Disk Space of CF Card Example 2 Change directory to root directory Example Terminal Mode cd dsize gt Change directory OK gt Total size 128032768 bytes 125 MB Example MCU Mode dir dsize dir 128032768 Operation List Directory Retum Value Filenames are returned with size of file inside Directory names are retum with brackets fime i i Tame ftime Filename 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 CF User Manual page 4 www comfiletech com 888 9CUBLOC Fax 650 638 1360 COMPILE TECHNOLOGY 42 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 directo
16. y to PC s serial port as PC uses 12V RS232 levels You need to use a MAX232 chip to convert 5V to 12V level before doing so 5 How to connect data lines m Processor Connection CUBLOC etc CUBLOC m CFIN Pin Connection You can check the status of CF card insertion by connecting CFIN pin to one of your processor s input pins Comfile Technology Inc CF User Manual page 2 www comfiletech com 888 9CUBLOC Fax 650 638 1360 COMFILE Serial CF Card Module User Manual C F TECHNOLOGY 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 w Hello World rin In CUBLOC Putstr 1 fouts test txt Aw Hellow World cr lf m Retum Values The CF COM will reply as follows lt Message gt Normal When command is processed successfully the CF COM will retum a capitalized O or in hex Ox4F Error When command is not processed successfully an error will occur and the CF COM will return a capitalized E or in hex 0x45 lt Data gt When reading a file the CF COM will return the data after the message MCU Mode and Terminal Mode lt

Download Pdf Manuals

image

Related Search

Related Contents

Biomass Daily System Manual  détérioration ou de mauvais fonctionnement  WALL MOUNTED TYPE INDOOR UNIT R410A X  Edsal CBD1836 Instructions / Assembly  Manuel d`installation  DeLOCK GX53 LED  HoMedics BA-110-EU massager  EK-KK11A-UG-001 KK11-A Cache Memory Users Guide Oct78  Aastra 9316CW User's Manual  User Manual PDF File  

Copyright © All rights reserved.
Failed to retrieve file