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

SD CARD CCS C
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9506
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jul 05, 2025 5:02 am     Reply with quote

it's because you MUST fix the hardware !
You must install 'logic level ' translation between the SD device and the PIC.
As Mr. T has pointed out the 3v SD can't send a '1' to the 5 v PIC.
NO code you try will work.

You must correct the hardware first THEN the software will work....
Ttelmah



Joined: 11 Mar 2010
Posts: 19890

View user's profile Send private message

PostPosted: Sat Jul 05, 2025 10:16 am     Reply with quote

Critical difference.

If you look at the SD module he is using there, it has level translator
hardware feeding the SD signals.The chip on the right (U1), has the
resistors necessary to pull up the SD lines, and this chip is level shifting
the signals for the SD. This is a properly designed module to drive an SD
from a 5v processor.
The LCD board you have does not have this level shifting. If you enlarge
the picture, you can see that the SD signals go directly to the connector pins.
No level shifting. Hence it _wiill not work_ (with a PIC).
The module he is using is this one:
[url]
https://www.switchelectronics.co.uk/products/micro-sd-card-mini-tf-reader-module?currency=GBP&variant=45334952280373&utm_source=google&utm_medium=cpc&utm_campaign=Google%20Shopping&stkn=bbf1d20e1ed7&gad_source=1&gad_campaignid=20470999819&gbraid=0AAAAAqEgT0CyMF-25WdEaLvA6rjxVP_Wh&gclid=Cj0KCQjwmqPDBhCAARIsADorxIZrqT-NdxVCAXBV5bapVpWcNwJ4IRAveNBVq68KcF-ezTsJQVbY0WEaAtS_EALw_wcB
[/url]

It is rather like putting diesel in a petrol car. Will not work, and can cause
damage.

As Jay says, you need to get the hardware right first. Software cannot fix
incorrect hardware. You can either add your own level translation
hardware, or switch to a module that does have this.
ilker07



Joined: 03 Jun 2022
Posts: 57

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 4:36 am     Reply with quote

Ttelmah wrote:
Critical difference.

If you look at the SD module he is using there, it has level translator
hardware feeding the SD signals.The chip on the right (U1), has the
resistors necessary to pull up the SD lines, and this chip is level shifting
the signals for the SD. This is a properly designed module to drive an SD
from a 5v processor.
The LCD board you have does not have this level shifting. If you enlarge
the picture, you can see that the SD signals go directly to the connector pins.
No level shifting. Hence it _wiill not work_ (with a PIC).
The module he is using is this one:
[url]
https://www.switchelectronics.co.uk/products/micro-sd-card-mini-tf-reader-module?currency=GBP&variant=45334952280373&utm_source=google&utm_medium=cpc&utm_campaign=Google%20Shopping&stkn=bbf1d20e1ed7&gad_source=1&gad_campaignid=20470999819&gbraid=0AAAAAqEgT0CyMF-25WdEaLvA6rjxVP_Wh&gclid=Cj0KCQjwmqPDBhCAARIsADorxIZrqT-NdxVCAXBV5bapVpWcNwJ4IRAveNBVq68KcF-ezTsJQVbY0WEaAtS_EALw_wcB
[/url]

It is rather like putting diesel in a petrol car. Will not work, and can cause
damage.

As Jay says, you need to get the hardware right first. Software cannot fix
incorrect hardware. You can either add your own level translation
hardware, or switch to a module that does have this.





https://hizliresim.com/jkyg6mx

this one and in the link you sent are equal??
Ttelmah



Joined: 11 Mar 2010
Posts: 19890

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 5:20 am     Reply with quote

No.

If you get the picture of the back of the board for that, the connections
to the SD card, just run directly to the pins. No level translation at all.
The SD card interface in the link I sent, has the IC on it to do the level
translation.
ilker07



Joined: 03 Jun 2022
Posts: 57

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 5:21 am     Reply with quote

Ttelmah wrote:
No.

If you get the picture of the back of the board for that, the connections
to the SD card, just run directly to the pins. No level translation at all.
The SD card interface in the link I sent, has the IC on it to do the level
translation.


Then ,why does not it work?I dont understand??
ilker07



Joined: 03 Jun 2022
Posts: 57

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 5:25 am     Reply with quote

Ttelmah wrote:
No.

If you get the picture of the back of the board for that, the connections
to the SD card, just run directly to the pins. No level translation at all.
The SD card interface in the link I sent, has the IC on it to do the level
translation.



if(fatopen((char *)"test.txt", (char *)"r", &myfile) != 0) fprintf(SCREEN,"fileerror\n");


else {

signed int ch_int;
unsigned char ch;
fprintf(SCREEN,"file ok\n");

fatseek(&myfile, 0, SEEK_SET);
ch_int=fatgetc(&myfile);
if (ch_int != EOF) {


ch=(char)ch_int;

fprintf(SCREEN,"%c",ch);

}


fatseek(&myfile, 1, SEEK_SET); // 2. character
ch_int=fatgetc(&myfile);
if (ch_int != EOF) {
ch=(char)ch_int;

fprintf(SCREEN,"%c",ch);
}



fatclose(&myfile);





}

it only says file ok!!!
temtronic



Joined: 01 Jul 2010
Posts: 9506
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 5:30 am     Reply with quote

You power the PIC with 5 volts, but the SD chip runs at 3 volts.

The SD chip can only give 3 volts for a '1' (high) BUT the PIC requires 5 volts for a '1'(high).

The PIC will NOT see ANY 'high' levels from the SD chip.

This is why you need 'logic level' convertors or translators'.They WILL change the 3 volts '1' signal from the sd chip into 5 volts that the PIC requires.
ilker07



Joined: 03 Jun 2022
Posts: 57

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 5:41 am     Reply with quote

Ttelmah wrote:
No.

If you get the picture of the back of the board for that, the connections
to the SD card, just run directly to the pins. No level translation at all.
The SD card interface in the link I sent, has the IC on it to do the level
translation.


but it works with arduino??
ilker07



Joined: 03 Jun 2022
Posts: 57

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 5:42 am     Reply with quote

temtronic wrote:
You power the PIC with 5 volts, but the SD chip runs at 3 volts.

The SD chip can only give 3 volts for a '1' (high) BUT the PIC requires 5 volts for a '1'(high).

The PIC will NOT see ANY 'high' levels from the SD chip.

This is why you need 'logic level' convertors or translators'.They WILL change the 3 volts '1' signal from the sd chip into 5 volts that the PIC requires.


but I can use it with Arduino.
Ttelmah



Joined: 11 Mar 2010
Posts: 19890

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 5:44 am     Reply with quote

Read the sticky at the top of the forum about this.
SPI, actually _requires_ the high level of the signals goes to 0.8* the
supply. So for the PIC 4v. A lot of chips do not implement this, so will
accept 3.3v. The PIC though does. The device you are showing does
not have the level translation to convert the SD card signals to suit
the PIC. The little SD card adapter used in the example you pointed to
does have this translation.
The code is never going to work without this.
No amount of fiddling is going to make it work until this is fixed.
ilker07



Joined: 03 Jun 2022
Posts: 57

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 6:54 am     Reply with quote

RC3, RC4 ==> 0.7 VDD

I think this the problem these pins accept at least 3.5 v
ilker07



Joined: 03 Jun 2022
Posts: 57

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 7:38 am     Reply with quote

but it says On-board 5V/3.3V level shifting IC, compatible with 5V/3.3V operating voltage. It has to work???
temtronic



Joined: 01 Jul 2010
Posts: 9506
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 8:00 am     Reply with quote

please post a link or product info of the LCD/SD module.
Many makers LIE about the 'level shifting'. Really need to see the ACTUAL schematic of the PCB to understand why ,but I suspect they're really saying 5 volts can't destroy the 3v SD chip onboard.

BTW the Arduino uses a different 'tech' under the epoxy than PICs do
Ttelmah



Joined: 11 Mar 2010
Posts: 19890

View user's profile Send private message

PostPosted: Mon Jul 07, 2025 11:12 pm     Reply with quote

The board has a 3.3v regulator to run the SD, but does not have level
shifting to the SD card. I looked at the image and you can see the tracks
go directly to the connector without level shifting.
The PIC is one of the few processors that insist on proper SPI signal
levels. This board will not work without added shifters.
ilker07



Joined: 03 Jun 2022
Posts: 57

View user's profile Send private message

PostPosted: Tue Jul 08, 2025 5:27 am     Reply with quote

Ttelmah wrote:
The board has a 3.3v regulator to run the SD, but does not have level
shifting to the SD card. I looked at the image and you can see the tracks
go directly to the connector without level shifting.
The PIC is one of the few processors that insist on proper SPI signal
levels. This board will not work without added shifters.



There are 2 74LVC245A IC on the shield.Arent they level-shifter 3.3 to 5 v??
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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