Thursday, October 30, 2014

Interfacing a color TFT display with the PIC32MX250F128B

I have been working on interfacing the PIC32MX250F128B with a small 2.2" TFT display from Adafruit. It's a nice little display that is fairly easy to communicate with, using SPI communication. The display I'm using is:

Adafruit provides nice open-source libraries for their products. However, they are for Arduino and thus cannot be directly reused for the PIC32. I went through the library and ported it over for the PIC32, in C. I have attached my project file as a .zip file and you can download it to go through the library header and source files, as well as the demo code. I've tried heavily commenting the code so that it is self-explanatory.

As far as hardware goes, with the demo code, the pin connections for the display are:

BL (backlight): I left it unconnected, but you can connect it to 3.3V for backlight.
SCK: connected to RB14 on the PIC
MISO: left unconnected, since I'm not reading anything from the screen
MOSI: connected to RB11 on the PIC
CS: connected to RB1 on the PIC
SDCS: left unconnected as I'm not using the microSD card for this
RST: connected to RB2 on the PIC
D/C: connected to RB0 on the PIC
VIN: connected to 3.3V supply
GND: connected to gnd

The pins I used are defined in the code and you can easily change them as required.

I used my custom proto-board for testing on a breadboard. You can find details here:

Here's a video showing the PIC32 running the demo code and doing some simple graphics on the screen. You can see that it runs fairly quickly and quite smoothly.

Project files with all source and header files:

If you have any comments, questions or suggestions, do let me know!


  1. Hi, please can you help me to realize project which is : solid state Marx-Bank generator :
    I have the program of PIC but i found difficulties in linking command circuit with power circuit , you do a great favor please,

  2. I went to buy the 2.2" TFT you used but it was sold out, so I got their 320x480 3.5" display instead. I further modified your code to build a pic32mx250 driver for the bigger display. This blog was super helpful in figuring out how to use the TFT, so thanks!

    TFT purchase link:
    3.5" TFT driver code:

  3. in the video i noticed you have capacitors and such that you don't say about, are they necessary because i what to use this in my project but i what to know what you say in the description is what you did in the video (is it for a 3.3V power supply).

    1. The only required circuitry for the interface are the point-to-point connections from the PIC32 to the LCD. The capacitors are there as bypass/filter caps for the 3.3V supply.

  4. sir, tahmid, can u please guide me to design true r.m.s voltmeter? please send me helping material @

  5. Very nicely done.

    One question though. How did you decide on the SPI frequency of 20MHz? Was it by experimentation?

    The datasheet for the Adafruit display shows an SCL (serial clock cycle write twc) minimum of 100ns which corresponds to a frequency of 10MHz. Did you find by experiment that it works even at 20MHz?

  6. Thank you for the code port to the PIC32 - I reported the code to a PIC32MZ running at 252 MHz - With the help of your code as a base I had the LCD running in about 3 hours. I appreciate your sharing. :-) Good day..... Signed, LostInSpace

  7. Thanks for your great and helpful presentation I like your good service.I always appreciate your post.Excellent information on your blog, thank you for taking the time to share with us.

  8. Hey Tahmid,

    I was windering if you could include the Plib.h file in the zip so it could more easily be ported over to another PIC32 device. Or perhaps paste it?



  9. Hi,

    The link is broken now.

    Can you post your code again.


  10. This is excellent information. It is amazing and wonderful to visit your site.
    Best Mobile Network Signal Repeater

  11. Display Technology also offer a bespoke design and manufacturing service to create the perfect display solution for you.We provide a range of embedded and display solutions from panel PC's.We will protect your personal information. click here