SD Card to RS-232

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Sat Dec 22, 2007 11:12 pm

I've had another look at the TXIF error and would suggest the following addition to the P18F67J60.inc file in the Mecanique/Swordfish/Includes folder (make a backup of this file first as it's a Swordfish system file) instead of the above suggestion I made:

Code: Select all

; PIR1
TMR1IF = 0
TMR2IF = 1
CCP1IF = 2
SSPIF = 3
TXIF = 4          ; added
TXIF_PIR1 = 4
RCIF = 5
ADIF = 6
SSP1IF = 3
TX1IF = 4
RC1IF = 5
Addition is at line 847.

The error arises because the P18F67J60 has two USARTs and the USART library always refers just to USART. The inc files normally alias USART1 to USART, so there is no problem, but for the P18F67J60 the TX interrupt flag for USART1 (TX1IF) is not aliased to TXIF. You are adding this alias with the above line.

I've tried compiling this and it's fine but have still not tested it in hardware.

Regards,

Steve

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

I tried that already

Post by Widgetman » Sun Dec 23, 2007 9:18 pm

Hi Steven,
I already thought about that. Is there a way to turn on any debug in the SDFileSystem.bas routines to see why it may be getting back a EOF all the time ?

I am working on writing a simple routine right now to print out the CID and CSD of a card. I will post it when I am done.

On the EOF error right now I am clueless. I am going to try and read another text file to see if it is a Binary issue or not. The test code I posted wrote test to a text file then read it out.

Thanks for the help

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Sun Dec 23, 2007 9:41 pm

The SD module doesn't distinguish between binary & text files - they are all just written and read as a series of bytes, so the file type should have no effect. Did you check the long file name issue I posted yesterday?

There is no debug written into the module, but you could make a copy of the module in the UserLibrary folder and edit it to add your own serial out routines for debug.

The CID and CSD routines would be interesting - could I add these to the module if you are successful?

Thanks,

Steve

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

It Works !!!

Post by Widgetman » Mon Dec 24, 2007 1:55 am

Hi Steven,
I was able to read my binary test file now and display it in the serial terminal window. I also verified that I could format the SD card as FAT using XP or format it with my test routine and the file could still be read ok. My next task is to tackle sending a file using the Z-Modem protocol. If anyone has any routines to look at or have experience with the Z-Modem protocol I would appreciate the help.
Thanks


PS I still think there is a bug in the compiler since I had to change the TXIF definition to the bit number for the 18F67J60

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

Post by Widgetman » Mon Dec 24, 2007 1:56 am

Hi Steven
When I figure out the CID and CSd routines you are welcome to add them to your library if you want.

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

CID and CSD reply

Post by Widgetman » Mon Dec 24, 2007 2:01 am

Hi Stevan
Listed below is the data from a CIS and CSD request I wrote using a C compiler for PIC's before I decided to switch to Swordfish. When I get a chance I will write the routines to do it in basic. Thanks for all the help

CID Request

Card Type Is 1
Manufacturer ID: 02
OEM/Application ID: TM
OEM/Application ID: SD256
Product Revision: 07
Serial Number: 7881AB64
Manufacturer Date Code: 0047
CRC-7 Checksum: 99

CSD Request

CSD_STRUCTURE: 00
TAAC: 2D
NSAC: 00
TRAN_SPEED: 32
CCC: 0135
READ_BL_LEN: 09
READ_BL_PARTIAL: 01
WRITE_BLK_MISALIGN: 00
READ_BLK_MISALIGN: 00
DSR_IMP: 00
C_SIZE: 33
VDD_R_CURR_MIN: 06
VDD_R_CURR_MAX: 06
VDD_W_CURR_MIN: 06
VDD_W_CURR_MAX: 06
C_SIZE_MULT: 05
ERASE_BLK_EN: 01
SECTOR_SIZE: 1F
WP_GRP_SIZE: 00
WP_GRP_ENABLE: 00
R2W_FACTOR: 05
WRITE_BL_LEN: 09
WRITE_BL_PARTIAL: 00
FILE_FORMAT_GRP: 00
COPY: 00
PERM_WRITE_PROTECT: 00
TMP_WRITE_PROTECT: 00
FILE_FORMAT: 00
CRC: EB

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

Fat 16 Works fine

Post by Widgetman » Sun Jan 13, 2008 3:49 pm

Hi Steven,
Sorry I hadn't gotten back to you sooner. I have been slammed with work and the Holidays. I was able to format a SD-Card in windows as FAT and drop any file on it. I then could read it out using my reader routines. I am still limited to 8.3 lengths on names, but for my application that is fine. I am on to the next stage of my project now. I need to send Serial data from a file and use Z-Modem protocol to wrap it. Has anyone done a Z-Modem protocol in the swordfish compiler language yet ?
Any thought or help would be appreciated.
Thanks

Post Reply