This small post shows a simulation example of SD card, ST7735R TFT (128×160) and PIC18F4550 microcontroller. The software used in this example is the well known simulation software ‘Proteus’.
In this example I’m going to store some image files (BMP format) on the SD card and display it on the ST7735R TFT screen.
Actually I made this example before using a simple hardware circuit. So if you want to build this example in reality see the project below:
Display BMP images from SD card on ST7735 TFT
As in the previous project, we need 3 files which are: ST7735 driver, SD card driver and FAT16 library. They can be downloaded from their topics below:
The ST7735 TFT display driver topic:
ST7735 SPI TFT Display Driver for CCS PIC C compiler
The SD card driver topic:
MMC/SD Card driver for CCS PIC C compiler
The FAT16 library topic:
FAT16 Library for CCS C compiler
Interfacing PIC Microcontroller with SD Card and ST7735R TFT Proteus Simulation Circuit:
Proteus circuit schematic diagram is shown below.
Interfacing PIC Microcontroller with SD Card and ST7735R TFT C Code:
The C code below is for CCS C compiler and it’s the same code which is used in previous project.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | // Display BMP images from SD card on ST7735 1.8" (128x160) TFT screen. // ST7735 TFT driver, MCC/SD card driver and Fat16 library for CCS C compiler // must be installed! // https://simple-circuit.com/ // TFT module connections #define TFT_CS PIN_D1 #define TFT_DC PIN_D0 #define TFT_SPI_HARDWARE // Hardware SPI module is used for the TFT // End TFT module connections #define DRAW_BMP_FROM_MMCSD_CARD // Enable BMP draw from MMC/SD card #define pixel_buffer 500 // Set pixel buffer to 500 // SD Card module connections #define SDCARD_SPI_HW // Hardware SPI module is used for the SD card #define SDCARD_PIN_SELECT PIN_D2 // End SD card module connections #include <18F4550.h> #fuses NOMCLR HSPLL PLL2 CPUDIV1 #use delay(clock = 48MHz) #use fast_io(D) #include <sdcard.c> // SD card diver source code #include <fat16.c> // FAT16 library source code #include <ST7735_TFT.c> // ST7735 TFT driver source code const int8 *txt = "FAT16 Initialization Error!"; int8 i = 'A', bmp[6]; void main(){ set_tris_d(0); // Configure PORTD pins as output delay_ms(2000); TFT_BlackTab_Initialize(); fillScreen(ST7735_BLACK); if(fat16_init() == 0){ strcpy (bmp, "A.bmp"); while(TRUE){ bmpDraw(0, 0, bmp); while(input(PIN_B2)); i++; if(i > 90) i = 'A'; bmp[0] = i; } } else drawtext(0, 10, txt, ST7735_YELLOW, ST7735_BLACK, 2); } |
Interfacing PIC Microcontroller with SD Card and ST7735R TFT Proteus Simulation Video:
The video below shows how the example works:
Proteus simulation file download link is below, use it with version 8.6 or higher:
Download
SD Card image file (images are included) download link is below:
Download
Hi there, thanks for all the work and effort put on your projects, I already tried to simulate your project in proteus but when I tried to compile the project a list of errors occurs in the fat16.c library starting at const int8 *fat_sign = {“FAT”}; line, do you know which could be the problem?
Thank you for sharing this great project and libraries
I am a retired person, the electronic project is very interested in, PIC microcontroller SD card and st7735r TFT Proteus simulation Study for some time, many places do not understand, but can not download, ask for help.
You are AMAZING ! Thank you for sharing this great project and libraries