CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

issues with mmcsd.c driver ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sapy44



Joined: 01 Feb 2004
Posts: 19
Location: Cedar Rapids, IA

View user's profile Send private message MSN Messenger

issues with mmcsd.c driver ?
PostPosted: Mon Mar 21, 2011 10:21 am     Reply with quote

All,


Is anyone aware of any bugs with the mmcsd.c driver available with the P.C.H I.D.E. V4.066 ?

I am trying to interface with a Lexar 1GB SD card, but can't get past the initialization phase. Keep getting an error code of 0x80 (timeout) from the init function.

I am using a 18F4685 with a level shifter I.C. (74LCX245) to convert the voltages and the H.W. S.P.I. available on port C, driver default.

Any suggestion are welcome.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 21, 2011 10:49 am     Reply with quote

Quote:

I am using a 18F4685 with a level shifter I.C. (74LCX245)

Did you build your own boards, or did you buy them ? I'm talking about
the PIC development board, and the SD Card adapter board.
If you bought the boards, post a link to the websites for them, and also
post a link to the schematics.
sapy44



Joined: 01 Feb 2004
Posts: 19
Location: Cedar Rapids, IA

View user's profile Send private message MSN Messenger

PostPosted: Tue Mar 22, 2011 11:39 pm     Reply with quote

Okay, here are links to documentation for the H.W. I'm using.


http://melabs.com/downloads/labx2sch_06.pdf

http://www.futurlec.com/Mini_Logic.shtml

http://www.futurlec.com/Mini_SC.shtml

I apologize in advance about the last two links as they do not contain all the information you may need. I will look to see how I can post the PDF files I received with these boards.
sapy44



Joined: 01 Feb 2004
Posts: 19
Location: Cedar Rapids, IA

View user's profile Send private message MSN Messenger

board info
PostPosted: Wed Mar 23, 2011 12:27 am     Reply with quote

Okay, I found some links to the board documentation.

http://home.att.ne.jp/green/w-elekitmart/MINILOGIC.pdf

http://mac6.ma.psu.edu/space2008/RockSat/microController/MINISD.pdf


Also, I'm using PN2222 transistors as two series logic inverters to connect the MISO line to the PIC from the SD card.

Also, I'm using a Lexar 1GB SD card.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 24, 2011 4:00 pm     Reply with quote

I didn't look at all your documentation in detail yet. But my experiments
with level-shifters between a PIC running at +5v and an SD Card running
at +3.3v show the following:

The notes below apply to the SCLK, SDO, and \CS, which come from
a +5v PIC and go to a 3.3v SD Card.

1. The 74VHCT125A is very unreliable as a 5v to 3.3v level shifter.

2. The 74LCX125 is somewhat unreliable.

3. Using 1.8K & 3.3K voltage dividers always works.

4. The 74LCX125 can apparently be made to work, if you put 100 ohm
series resistors between the PIC pins and inputs to the 74LCX125 pins
for SCLK, SDO, and \CS. The resistors should be placed close to
the PIC pins. They dampen out noise before it can be amplified by
the 74LCX125.

5. The following article explains the noise amplification problems with
level shifters such as the 74VHCT125A:
http://www.electronic-products-design.com/geek-area/electronics/pcb-design/high-speed/signal-noise-issues-with-modern-clocked-devices
My experiments show that the "LCX" series has the same problems, but
not as much. It can probably be fixed with the series resistors.

I am still doing experiments to try to make the 74VHCT125A work.
I don't have any conclusions yet.
sapy44



Joined: 01 Feb 2004
Posts: 19
Location: Cedar Rapids, IA

View user's profile Send private message MSN Messenger

level shifting
PostPosted: Thu Mar 24, 2011 5:26 pm     Reply with quote

PCM,

I will try it with the voltage divider combo you suggested. This should eliminate the I/O levels as an issue. Hopefully everything else is ok.

Do you have any thoughts on the MISO line. Is my double NPN transistor inverter scheme acceptable ?

I will post again if I discover anything new. Thanks for the tip.
sapy44



Joined: 01 Feb 2004
Posts: 19
Location: Cedar Rapids, IA

View user's profile Send private message MSN Messenger

update
PostPosted: Fri Mar 25, 2011 12:04 am     Reply with quote

Some progress was made today. I used the voltage divider on the inputs to the SD card and was able to get back CSD and CID data using the corresponding functions found in the driver.

However, I am still having trouble with read and writes. See my code below:

Code:


#include <LAB-X2_PIC18F4685.h>
#include "mmcsd.c"


#define ADDR 512000000
#define VAL 73

void main()  {

unsigned int8 init_status=0xFF, read_status =0xFF, write_status =0xFF,flush_status =0xFF;
BYTE cap_char= '\0';


init_status=init_status=mmcsd_init();
delay_us(50);


read_status=mmcsd_read_byte(ADDR, &cap_char);
write_status=mmcsd_write_byte(ADDR, VAL);
flush_status=mmcsd_flush_buffer();
read_status=mmcsd_read_byte(ADDR, &cap_char);

fprintf(RS232,"Write status = %u \r\n Flush status = %u \r\n Read status = %u \r\n",
                                          write_status,flush_status,read_status);
fprintf(RS232,"Cap Data = %c \r\n",cap_char);


       }//end main()



The init function works fine and returns 0 to init_status.

The first read returns 128 (0x80) corresponding to a timeout.

The following write returns a 0, for a good operation.

The flush returns a 127 (0xFF). No defined error code for that.

The final read returns a 0, with cap_char = 73, but this is simply reading from the global buffer, g_mmcsd_buffer, and not the device.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group