View previous topic :: View next topic |
Author |
Message |
ilker07
Joined: 03 Jun 2022 Posts: 46
|
SD CARD CCS C |
Posted: Fri Jun 27, 2025 1:15 am |
|
|
Hi eveyone,I try to use sd card(480*320 ILI9486) with PIC18F67K22.I use Kingston 8 gb sd card I formatted sd as FAT32 and I put test.txt file and put 'G' character but i gives me 'B' character when I try to read the file.Then I replaced the 'G' with 'A' but it gives me 'B' again .What is the problem??
#include <18F67K22.h>
#use delay(xtal=20MHz,clock=80MHz)
#use fast_io(c)
#define MMCSD_PIN_SCK PIN_C3 //o
#define MMCSD_PIN_SDI PIN_C4 //i
#define MMCSD_PIN_SDO PIN_C5 //o
#define MMCSD_PIN_SELECT PIN_E1 //
#include <mmcsd_m.c>
#include <fat_m.c>
void main() {
int8 i;
FILE myfile;
i = fat_init();
if(i != 0) tft_fill_color(0xf800); //red
else {
if(fatopen((char *)"/test.txt", (char *)"r", &myfile) != 0) tft_fill_color(0x001F);
else {
signed int ch_int;
char text[10];
fatseek(&myfile, 0, SEEK_SET); // begining of the file
ch_int=fatgetc(&myfile);
if (ch_int != EOF) {
unsigned char ch=(char)ch_int;
drawChar16x32(100,100,ch,0xffff,0x0000);
fatclose(&myfile);
}
}
}
while(TRUE) ;
} |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9480 Location: Greensville,Ontario
|
|
Posted: Fri Jun 27, 2025 5:10 am |
|
|
hmm quick basic hardware questions
1) what VDD running the PIC on ?
2) proper pullups/downs/ caps for the SD card ? |
|
 |
ilker07
Joined: 03 Jun 2022 Posts: 46
|
|
Posted: Fri Jun 27, 2025 6:14 am |
|
|
temtronic wrote: | hmm quick basic hardware questions
1) what VDD running the PIC on ?
2) proper pullups/downs/ caps for the SD card ? |
5v and There are no pull up or donw resistors.. |
|
 |
ilker07
Joined: 03 Jun 2022 Posts: 46
|
|
Posted: Fri Jun 27, 2025 6:20 am |
|
|
temtronic wrote: | hmm quick basic hardware questions
1) what VDD running the PIC on ?
2) proper pullups/downs/ caps for the SD card ? |
[img] [/img] |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19872
|
|
Posted: Fri Jun 27, 2025 6:51 am |
|
|
OK.
That has a voltage regulator to give the 3.3v for the SD card, but does not
have any level translation for the SD.
You need to read the sticky at the top of the forum about 5v and 3.3v devices,
and add level translation to your circuit. Also you need to be very careful
about having a good supply capacitor close to the 5v connection. The unit
is a little 'naughty' (doesn't actually meet the SD recommedations, about the
decoupling provided to the SD itself.
Read the sticky. It describes the circuits you need.
You also need to look at the code library, and get the modified drivers
for high capacity SD cards.
As a community, 'hopefully you have the voltage regulator enabled.
This is required above 3.6v.
Also the chip is not rated to run to 80MHz. 64MHz max. The maximum
crystal frequency with the PLL enabled is 16MHz. Look at table 31-7
section 1A in the data sheet. |
|
 |
ilker07
Joined: 03 Jun 2022 Posts: 46
|
|
Posted: Fri Jun 27, 2025 9:28 am |
|
|
Ttelmah wrote: | OK.
That has a voltage regulator to give the 3.3v for the SD card, but does not
have any level translation for the SD.
You need to read the sticky at the top of the forum about 5v and 3.3v devices,
and add level translation to your circuit. Also you need to be very careful
about having a good supply capacitor close to the 5v connection. The unit
is a little 'naughty' (doesn't actually meet the SD recommedations, about the
decoupling provided to the SD itself.
Read the sticky. It describes the circuits you need.
You also need to look at the code library, and get the modified drivers
for high capacity SD cards.
As a community, 'hopefully you have the voltage regulator enabled.
This is required above 3.6v.
Also the chip is not rated to run to 80MHz. 64MHz max. The maximum
crystal frequency with the PLL enabled is 16MHz. Look at table 31-7
section 1A in the data sheet. |
You said
You also need to look at the code library, and get the modified drivers
for high capacity SD cards. which part? |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19872
|
|
Posted: Fri Jun 27, 2025 9:59 am |
|
|
[url]
https://www.ccsinfo.com/forum/viewtopic.php?t=53787
[/url]
The key part is the SDHC driver, if you have the latest CCS drivers.
However you need to get the chip running at a legal speed, the pull up
resistors and the level translation sorted before the drivers will work.
Currently the signals from the card will not meet the SPI input specification
of the PIC, and you also could damage the inputs to the SD. The wake up
operating mode, may well function, but is not guaranteed unless you add the
resistors as well. |
|
 |
|