Breadboard MightyCore 1284p - Adafruit ILI9340 LCD driver - SPI pin assignment?

Hi All,

I have recently got the excellent MightyCore working on a 1284p breadboard and am attempting to run an SPI 2.2 LCD screen off it resulting in a white screen.

OSX 10.10, Arduino 1.6.5, MightyCore 1284p with bootloader v1.0.3-r1

The sketch is (Adafruit’s graphicstest) & uploads & runs well on the 1284p itself - I can see the output progress in the Arduino serial monitor, however I don’t think the ILI9340 driver on the LCD is getting the data - even though I can see the LEDs pulsing on the logic level converter between the 1284p and the LCD (3.3v). The full library repo is here.

The library runs great on a standard Diecimila 328

Here’s the wiring on the working setup:

Diecimila <----> ILI9340 pins (via 5 to 3.3v LLC where needed)

D13----SCK
D12----MISO
D11----MOSI
D10----CS
D9-----D/C
3.3v—RESET (can be optionally connected to pin 8, but here pulled high)
3.3v—LED
3.3v—3.3v
GND—GND

For the 1284p, I’ve tried using the SPI hardware pins per MCUdude’s pinout here and set the CS to pin D10 - with no activity onscreen:

Mightycore 1284p <----> ILI9340 pins (via 5 to 3.3v LLC where needed)

D7----SCK
D6----MISO
D5----MOSI
D10----CS
D9-----D/C
GND—GND

3.3v—RESET (can be optionally connected to pin 8, but here pulled high)
3.3v—LED
3.3v—3.3v (note: the 3.3v connections to the LLC & LCD are being supplied via a separate 3.3v USB FTDI ( with a common ground to the breadboard & 1284p) no DTR, RX or TX are connected from this, just the 3.3 and GND).
GND—GND

Context note:
The LCD is meant to be one of two SPI devices running off this 1284p - the other device is an Adafruit CC3000 which I have the Buildtest sketch working great. It works off the SPI hardware pins fine, however the library needed some slight adjustments found here . In summary adjustments were to the Adafruit_CC3000.cpp file where he added this:

/* start support for 1284p */ 

#elif defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__)|| defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega644PA__) 
2, 2, 
11, 1, 
10, 0, 

/* end support for 1284p */

So, as this is SPI and working - I was comparing these updates to files in the Adafruit_ILI9340 to see if there was something that stood out, but out of my depth on this!

Another thing I tried was using the software option at the top of the ‘graphicstest’ sketch with appropriate wiring - no change.

If it’s helpful, the graphicstest sketch and the verbose output on upload is attached.

Any pointers on what to try next much appreciated!

Thanks,
Rich.

graphicstest_sketch_verbose_output.txt (14.8 KB)

graphicstest_sketch_as_uploaded.txt (12 KB)

Actually, I got the exact same LCD! I gt it working with the ATmega1284 together with the Ucglib library. Your setup looks OK, but I wouldn't use pin D9 and D10 for anything else than the Serial monitor. Try moving the CS pin to D4, and the D/C-pin to D3

hansibull:
Actually, I got the exact same LCD! I gt it working with the ATmega1284 together with the Ucglib library. Your setup looks OK, but I wouldn't use pin D9 and D10 for anything else than the Serial monitor. Try moving the CS pin to D4, and the D/C-pin to D3

Awesome choice on the LCD!
I'll give those pins a shot tonight - thanks hopefully that will help on the 1284p.

BTW - I also got the SD card sketch spitftbitmap ( to work on the Diecimila 328 setup after adding a header pins to the screen.

R

hansibull:
Try moving the CS pin to D4, and the D/C-pin to D3

Thanks Hans, gave it go, still no activity on the LCD. The connecting wires are all freshly made from AWG 22 & the breadboard is new too & I swapped out the LCD. Gotta be something simple..

Rich,

I use the Bobuino pinout, so I didn't check the pins, but I would suggest good ol' troubleshooting.
Unplug everything except the LCD and see if you can output to it from a separate sketch.
I'm sure you know that to share SPI you need separate select pins for each device.
Since most libraries were written for Arduino, they would expect pins 10 to 13, so you may need to do some tweaking to replace 10 with another pin for the other SPI device.

somedude:
Unplug everything except the LCD and see if you can output to it from a separate sketch.
I'm sure you know that to share SPI you need separate select pins for each device.

Thanks Somedude,

Yep, the LCD is the only peripheral powered on the breadboard, the CC3000 is still there with some wires still connected to the same SPI, (with a different CS as you mentioned) but not powered up so I'd assumed that it was inert & not affecting anything. I can remove it though just to double check.

The 1284p MightyCore has the hardware SPI working on these pins:
D7----SCK
D6----MISO
D5----MOSI

And it works great with the other Adafruit library (for the CC3000) I tried- so I think the pin assignments for SPI are taken care of in MightyCore's SPI that compiles with the sketch. The only thing that needed changing in the Adafruit CC3000 library that normally uses pins 10 to 13 on a 328 was to add in the interrupt pin definitions (as below).

It's possible that the library for the CC3000 already has support for the hardware pins on a 1284p in it & the ILI9340 library may not - I'm not familiar with how to interpret the 'avr-libc' style code to be able to determine that for sure!

Rich.

richCarthew:
CC3000 is still there with some wires still connected to the same SPI, (with a different CS as you mentioned) but not powered up so I'd assumed that it was inert & not affecting anything.

bad assumption. removing power does not disable signal pins on most devices. clamping diodes and forward biased junctions still there dragging things down.

that tft has become one of my favorite displays after having been lucky to snag (b.o.) a large qty of them off ebay for even less than cheapie 2 line lcd. bad luck trying to get it working with non-standard target so took a step back and succeeded immediately using m328 with adafruit arduino library. then it was a cinch porting to other avrs and even translate into my preferred language, assembly.

arduino is not my main goto toolset but it sure cuts development time for some of the more complicated and otherwise tricky projects like this. speeds things up by a factor of 10 or sometimes even 100.

john1993:
bad assumption. removing power does not disable signal pins on most devices. clamping diodes and forward biased junctions still there dragging things down.

Good to know John, thanks.

john1993:
then it was a cinch porting to other avrs

Care to elaborate on your method of 'easy porting' to other libraries from the 328?

Cheers, Rich.

Well, you could also try switching to the Bobuino pinout, which has the highest degree of compatibility with Arduino libraries, at least temporarily until you figure things out.
Who knows, you might like it... :wink:

I use it and I am yet to come across a library that won't work. SPI, I2C, UART, analog pins, all match up to the Uno.

I got the LCD working with my ATmega1284p using the standard pinout. I found a guide for the arduino UNO, and figured out what the pinout will be on the 1284p.
Here is the connection:
Arduino pin: LCD pin:
D7 SCK
D5 SDA
D4 CS
D3 AO
D2 RESET

The output using the Adafruit ILI9340 library is a bit glitchy. It seems like it's only updating 1/3 of the screen properly. Here's a picture:

I also tested the same LCD with the exact same configuration using Ucglib. I added this constructor:

Ucglib_ST7735_18x128x160_HWSPI ucg(/*dc=*/ 3 , /*cs=*/ 4, /*reset=*/ 2);

to the graphicstest.ino file.

The output from Ucglib is really looking good!

EDIT__
It seems like you got the 320x240 version of the LCD.
try using this construction instead:

//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*dc=*/ 3 , /*cs=*/ 4, /*reset=*/ 2);

richCarthew:
Care to elaborate on your method of 'easy porting' to other libraries from the 328?

actually same library, different targets. the main task was get going on the m328 which was the warm and fuzzy standard to settle display wiring and function. then m8 which went pretty smooth because its same pinout. next m32 required a little work because pins were different but internally same as m8. the trick was checking to make sure signals coming out the right pins before even hooking up the tft. things went easy from that point.

some rainy day i may give m1284 a try since m32 is often a drop in replacement for that and m128 now that its got arduino support.

Thanks for all the extra info and tips guys!

Been away from this a couple of days - will find some time hopefully today to re-read your replies and try some stuff out.

Will let you know how I get on!

Cheers, Rich.

Hi guys!

Well, you could also try switching to the Bobuino pinout

somedude:

Gave that a whirl and double checked my pinouts - no joy yet...

hansibull:
I got the LCD working with my ATmega1284p using the standard pinout. I found a guide for the arduino UNO, and figured out what the pinout will be on the 1284p.
Here is the connection:
Arduino pin: LCD pin:
D7 SCK
D5 SDA
D4 CS
D3 AO
D2 RESET

Hi Hans, Thanks for the update. I must admit this set up has me a bit confused because of the SDA pin mentioned - isn't that for the I2C or Wire library? - also I like the look of the SPI lib UcGlib, although when I looked at it more, I couldn't find a reference to loading a 320 x 240 bitmap like I can on the 328 with the Adafruit!

I spent some more time reassigning some pinouts on the 1284p for the CS etc but still the white screen.

john1993:
...the trick was checking to make sure signals coming out the right pins before even hooking up the tft.

Thanks John1993.
When you measure the signals, are you using some feedback within the sketch to the Arduino IDE's serial monitor or using some sort of equipment like an oscilloscope?

I guess I have 2 options going forward - 1) keep trying with the 1284p & maybe buying an 'Official' Adafruit LCD to see if I can ask them about their library w.r.t. 1284p as it's also their CC3000 I'm using in the project,
OR
Use two 328's in my design - one for the CC3000 (Master) which sends info to the slave with the LCD.. this is a real fall-back option though :slight_smile:

Cheers,
R

richCarthew:
Thanks John1993.
When you measure the signals, are you using some feedback within the sketch to the Arduino IDE's serial monitor or using some sort of equipment like an oscilloscope?

led on a wire which is my #1 debug tool. swinging it around with a little experience you can actually determine spi and i2c signals. in the case of tft just seeing activity on the pins was enough. the key to working with this stuff, as mentioned, is get your feet on the ground (uno/m328) then baby steps.

i do have an antique tek tds220 dso which i fire up on those rare occasions when led or dmm is not enough. also rigol 4ch which i find little use for so gathering dust.

Hi

Im trying to use too the adafruit LCD library but with atmega644p (i have the Mightycore board library)and im getting error in the compilation. The atmega1284 is a version with twice the memory and same pin numbers so the pins configuration maybe similar to fix.

I don’t have the skills to configure in low lvl the library. Help