SD-Card with CCS C Compiler using pic microcontoller




Description

This project shows how to use a SD-Card with FAT16 file system. It is based on the example MMC/SD-Card driver (mmcsd.c) and FAT file system driver (fat.c) delivered with the CCS C compiler. Unfortunately, the example didn’t work properly for me. So I searched the web and found some required changes to make it work. All modifications are described in the following article.

SD-Card with CCS C CompilerHardware

SD-cards can be interfaced to a microcontroller via SPI-Bus, hence only 4 I/O pins (SDI, SDO, SCK, CS) are required to connect the SD-card to the PIC.

SD-cards operate at 2.7V .. 3.6V while the 18F PICs usually operate at 5V. Hence a voltage level translation is required for the SD-card inpus (SDI, SCK, CS). There are a lot of examples available in the web where a voltage divider with resistors is used to translate the 5V signals to 3.3V. This will work, but at higher SPI speeds this might cause problems. Due to that, I used a 74AC125 buffer to do the level translation which works more reliable than the voltage divider.

SD-Card Module

Here the schematic of the SD-Card module with the voltage level translation. The pins on the connector SV1 need to be connected to the microcontroller pins.

Important: SDO and SDI are the pin names from the SD-card point of view, i.e. SDO needs to be connected to SDI on the microcontroller and SDI needs to be connected to SDO in the microcontroller!

SD-Card with CCS C CompilerSoftware

As mentioned in the description for this article, I used the ex_fat.c example which is delivered with the CCS C compiler.

Unforunately, when I run the demo and created some files with the demo, I was not able to see the files when I pluged the SD-card into my PC. After some investigations I found a solution for this problem in the CCS forum which I will summarize here.

 

For more detail: SD-Card with CCS C Compiler




Current Project / Post can also be found using:

  • pic c programming with ccs c compiler pdf
  • PİC sd kart ccs c
  • PIC USB CCS-C

Leave a Comment

*
= 3 + 1

Read previous post:
Driving a piezo speaker with a PIC using pic-microcontroller,

Overview A Pulse Width Modulation (PWM) output from a PIC microcontroller can be used to play tones on a piezo...

Close
Scroll to top