Jump to content
43oh

TivaC with 5110 Nokia LCD


Recommended Posts

Hi all,

I have some troubles with Nokia 5110 LCD to run on Tiva C using Energia. Here is my full code.

 

I wire as below:

PA_7,    // Chip Select
PA_2,    // Data/Command
PB_5,    // Reset
PA_6,    // Backlight
PB_4 = SCK (2) = Serial Clock
PB_7 = MOSI (2) = Serial Data
 
I'd done compiled and uploaded the code onto the chip but there was nothing displayed on the 5110 Screen. I still can toggle the backlight on/off by the push button, it means that the loop is running. I think there may be some issues with the SPI driver.
 
Thank you a lot,
 
For your easy reference, I post the main .ino code here for preliminary skimming:
#include "Energia.h"
// Core library for code-sense
#if defined(WIRING) // Wiring specific
#include "Wiring.h"
#elif defined(MAPLE_IDE) // Maple specific
#include "WProgram.h"
#elif defined(MPIDE) // chipKIT specific
#include "WProgram.h"
#elif defined(ENERGIA) // LaunchPad, FraunchPad and StellarPad specific
#include "Energia.h"
#elif defined(CORE_TEENSY) // Teensy specific
#include "WProgram.h"
#elif defined(ARDUINO) && (ARDUINO >= 100) // Arduino 1.0 and 1.5 specific
#include "Arduino.h"
#elif defined(ARDUINO) && (ARDUINO < 100) // Arduino 23 specific
#include "WProgram.h"
#else // error
#error Platform not defined
#endif


// Include application, user and local libraries
#include "SPI.h"
#include "LCD_5110_SPI.h"


// Variables
/// P._. / PB_4 = SCK (2) = Serial Clock
/// P._. / PB_7 = MOSI (2) = Serial Data


#if defined(__MSP430G2553__)
LCD_5110_SPI myScreen;
#elif defined(__LM4F120H5QR__)
LCD_5110_SPI myScreen(PA_7,    // Chip Select
PA_2,    // Data/Command
PB_5,    // Reset
PA_6,    // Backlight
PUSH2);  // Push Button 2
#endif
boolean backlight = false;
uint8_t k = 0;




// Add setup code
void setup() {
#if defined(__MSP430G2553__)
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV2);
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE0);


#elif defined(__LM4F120H5QR__)
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV128); // for LM4F120H5QR DIV2 = 4 MHz !
#endif


  myScreen.begin();


  myScreen.setBacklight(backlight);
  myScreen.text(0, 0, "Hello!");


  delay(1000);
  myScreen.clear();
  myScreen.text(0, 5, "Light off");
}


// Add loop code
void loop() {
  if (myScreen.getButton()) {
    backlight = (backlight==0);
    myScreen.setFont(0);
    myScreen.text(0, 5, backlight ? "Light on " : "Light off");
    myScreen.setBacklight(backlight);
  }


  myScreen.setFont(1);
  if (k==0)   myScreen.text(0, 2, " MSP430");
  else if (k==8)   myScreen.text(0, 2, "  LM4F  ");


  myScreen.setFont(0);
  for (uint8_t i=0; i<14; i++) myScreen.text(i, 4, (i==k) ? "*" : " ");
  k ++;
  k %= 14;


  delay(200);
}

Nokia5110.rar

Link to post
Share on other sites

You need to use the pins numbers instead of the ports and bits names.

 

Please refer to the pins maps at http://energia.nu.

Thanks Velo, but I'm afraid I don't fully understand. Do you mean to change the following lines? (e.g. change PA_7, PA_2... into pin numbers)

#if defined(__MSP430G2553__)
LCD_5110_SPI myScreen;
#elif defined(__LM4F120H5QR__)
LCD_5110_SPI myScreen(PA_7,    // Chip Select
PA_2,    // Data/Command
PB_5,    // Reset
PA_6,    // Backlight
PUSH2);  // Push Button 2
#endif

As what I done I can still toggle the backlight after uploading the code. It means using port names didn't affect, isn't it?

Link to post
Share on other sites

I've change as what you suggested, but... no hope.

 

#if defined(__MSP430G2553__)
LCD_5110_SPI myScreen;
#elif defined(__LM4F120H5QR__)
LCD_5110_SPI myScreen(10,    // Chip Select
11,    // Data/Command
2,    // Reset
9,    // Backlight
PUSH2);  // Push Button 2
#endif
boolean backlight = false;
uint8_t k = 0;

How about the Serial clock and Serial data? I connected them to PB_4 and PB_7 respectively.

Link to post
Share on other sites

It seems very weird. This project (5110 LCD) and the LCD 16x2 project, and also a 7-segment LED project I run successfully on Arduino. However using Tiva C with Energia it didn't work although I used the pin numbers instead of port names. Is there anything to do with the clock frequency that affects the timing (tiva C is much faster than Arduino?)

Link to post
Share on other sites
  • 3 weeks later...

It seems very weird. This project (5110 LCD) and the LCD 16x2 project, and also a 7-segment LED project I run successfully on Arduino. However using Tiva C with Energia it didn't work although I used the pin numbers instead of port names. Is there anything to do with the clock frequency that affects the timing (tiva C is much faster than Arduino?)

hello, i have the 5110 working with tivaC. i think i had to change the spi clock divider and spi mode.

 

also i remember, different batches of screen from different sources required different settings.

 

 

 

 

Sent from my iPhone using Tapatalk

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...