View previous topic :: View next topic |
Author |
Message |
sapy44
Joined: 01 Feb 2004 Posts: 19 Location: Cedar Rapids, IA
|
issues with mmcsd.c driver ? |
Posted: Mon Mar 21, 2011 10:21 am |
|
|
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
|
|
Posted: Mon Mar 21, 2011 10:49 am |
|
|
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
|
|
|
sapy44
Joined: 01 Feb 2004 Posts: 19 Location: Cedar Rapids, IA
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 24, 2011 4:00 pm |
|
|
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
|
level shifting |
Posted: Thu Mar 24, 2011 5:26 pm |
|
|
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
|
update |
Posted: Fri Mar 25, 2011 12:04 am |
|
|
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. |
|
|
|