chipKIT® Development Platform

Inspired by Arduino™

Adafruit tft 2.2" ili9340c and chipkit uc32 How can I make it work

Created Mon, 25 Jul 2016 20:08:54 +0000 by Francois9999


Francois9999

Mon, 25 Jul 2016 20:08:54 +0000

Hello,

I have a program suited for Arduino Uno to use the tft screen from Adafruit. They give all you need to make it work. I was wondering if it was easy to transfer it to the chipkit uc32. Here is the link

https://www.adafruit.com/product/1480. They give the GFX and TFT library and the program graphictest in arduino uno Avr type of microcontroller. It work on the Arduino but when I try to transfer it on the chipkitUC32 there is error about the pins of the spi. I would like to make it work on that platform or the chipkitMax32 or chipkit WF.

I program the chipkit uc32 in the Arduino IDE with the chipkit core but I have those error. I would like to be able to use the same pins of the Arduino if possible. 13=sck, 12= miso, 11=mosi, 10=cs, 9=RST, 8=D/C and 4=SD/SC for the sd card.

I tried small program from Arduino to Chipkit and it was working fine but now I need to understand How to modify header I guess to make it work.

Sharon told me that Majenko did a display core for that and I downloaded the link but I don't know how to make it work together.

I have seen that Digilent made a library Dspi but I'm bugded and sometimes they put ifndef pic32MX etc... I just don't know where they took it from maybe from the xc compiler from Microchip but it's all fuggy to me at the moment.

Can you help me, please !

Best Regards,

Francois


majenko

Tue, 26 Jul 2016 17:37:48 +0000

The Adafruit ILI9340C TFT screen is the second screen I ever got back at the beginning of making the TFT library which later became DisplayCore - so I know it works, and works well.

You need three libraries:

  • DisplayCore: [url]https://github.com/MajenkoLibraries/DisplayCore/tree/master/DisplayCore[/url]
  • The ILI9340 driver: [url]https://github.com/MajenkoLibraries/DisplayCore/tree/master/Drivers/ILI9340[/url]
  • DSPI: This is included in chipKIT-core.

Plus any other parts of DisplayCore you may want at a later date (Widget sets, Fonts, Icons, etc). Simplest to just install the entire lot.

Then it's very simple to get it going. This little program displays the value of "millis()" on the screen:

#include <DisplayCore.h>
#include <DSPI.h>
#include <ILI9340.h>

DSPI0 spi;
ILI9340 tft(spi, 10, 8, 9);

void setup() {
	tft.initializeDevice();	
	tft.fillScreen(Color::Black);
	tft.setTextColor(Color::Red, Color::Black);
	tft.setFont(Fonts::Default);
}

void loop() {
	tft.setCursor(20, 20);
	tft.print(millis());
}

The three numbers in the tft constructor are the CS (10), D/C (8) and RES (9) pins. Connect:

  • GND -> GND
  • VIN -> 3.3V
  • D/C -> 8
  • RST -> 9
  • SDCS -> Not needed unless you want to use the SD card slot
  • CS -> 10
  • MOSI -> 11
  • MISO -> Not needed unless you want to use the SD card slot
  • SCK -> 13
  • BL -> Not needed unless you want to control the backlight.

Francois9999

Tue, 02 Aug 2016 21:44:54 +0000

Hello,

Thank You for your reply.

I just don't know if I should use Arduino IDE with the integrated chipkit core or the MPIDE 023 or the pickit3 with mplabx to program it.

Is the bootloader will still be there? Where should I put those librarys. In the Arduino IDE Library or Chipkit core and where is the chipkit core library? I don't see it on my C drive even if I install it in Arduino IDE. I just don't know which one the compiler is going to use.

I tried to put all those library in the sketch of the Arduino IDE that it produce from your copy and paste code to the Arduino IDE and selecting chipKitUC32 and I have error when compiling. It's a bit messy on How to use the digilent chipkit card with Arduino IDE, MPIDE that they said that it was replace from the new Arduino IDE ( I have version 1.9 ) or should I use Mplabx and pickit 3 to program it. Thank You, Best Regards,

Francois


majenko

Wed, 03 Aug 2016 10:01:53 +0000

Using the Arduino IDE libraries go in the libraries folder in the Arduino folder in your documents.

Personally though I'd use UECIDE (of course) where you can install the DisplayCore libraries you need using the Plugin Manager. Much much simpler.

Stay away from using MPLAB-X and the PICkit3 unless you need to do hardware-level debugging. Using that you will eradicate the bootloader and break the board for using Arduino or UECIDE, until you have put the bootloader back in place.