![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
bru.balazs
Joined: 26 Oct 2014 Posts: 1
|
Sd card 1gb, 18F4550 spi |
Posted: Tue Mar 24, 2015 3:13 am |
|
|
Hello
I need example program. I use spi mode. I have 18f4550, and 1 GB sd card. My program read only "0".
Can you help everyone? Thankyou for your help.
My program:
Code: |
setup_spi(SPI_MASTER | SPI_SCK_IDLE_LOW | SPI_CLK_T2 | SPI_SAMPLE_AT_END | SPI_XMIT_L_TO_H);
mmc_init();
for(int32 i = 1; i<=500000;i++)
{
mmc_read_byte( i, SD_data);
if(SD_data != 0x0000)
{
Y_koord=200;
X_koord++;
FillArea(X_koord, Y_koord, 5,5, SD_data);
delay_ms(8);
}
}
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Mar 24, 2015 8:07 am |
|
|
Almost certainly not....
Try searching here.
How is the card interfaced to the chip?.
Go here:
<http://www.smallridge.com.au/index.php?page=projects#HWREF>
Load the 184620 reference design for Ethernet.
Now look at how the SD card is connected. Is your's connected like this?.
To drive the SD card with a 5v PIC, _requires_ (not optional), some form of level translator chip for the signals from the card to the PIC. There are (sadly) dozens of circuits on the web, that omit this. These will not work.
Then you need certain signals pulled up to ensure the card wakes up in the right mode, and also that the data line floats high when not connected, and resistive dividers _or_ another translator for the signals the other way.
This has been covered literally hundreds of times here. People who do the interface correctly (or use a 3.3v PIC), have working circuits. People without these, have problems.
You also don't show how you are programming Timer2 (which determines your SPI rate). The SPI must wake up at a slow speed, and only switch up to full speed once the card is programmed. The rate must be below 400KHz, and should be 100KHz or greater (some cards have problems if you are below this), for the initialisation. After this, the rate can go as fast as the PIC can handle.
You also can't just read data from the card like this. It needs initialisation _first_. Look at the supplied MMC/SD examples, and how they setup the card. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|