Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Strange behavior pinMode/digitalWrite within library

$
0
0

Hello,

I've done a TIVA C-123-Launchpad conversation of Henning Karlsen's LCD5510 library (it's much the same as the UTFT library).

Everything is working, BUT:

I've to eliminate following code (commented out part) in the *.cpp file, and I've to do it manually in "setup" sketch:

LCD5110::LCD5110(int SCK, int MOSI, int DC, int RST, int CS)
{
	P_SCK	= portOutputRegister(digitalPinToPort(SCK));
	B_SCK	= digitalPinToBitMask(SCK);
	P_MOSI	= portOutputRegister(digitalPinToPort(MOSI));
	B_MOSI	= digitalPinToBitMask(MOSI);
	P_DC	= portOutputRegister(digitalPinToPort(DC));
	B_DC	= digitalPinToBitMask(DC);
	P_RST	= portOutputRegister(digitalPinToPort(RST));
	B_RST	= digitalPinToBitMask(RST);
	P_CS	= portOutputRegister(digitalPinToPort(CS));
	B_CS	= digitalPinToBitMask(CS);
    
    /*
	pinMode(_SCK,OUTPUT);
	pinMode(_MOSI,OUTPUT);
	pinMode(_DC,OUTPUT);
	pinMode(_RST,OUTPUT);
	pinMode(_CS,OUTPUT);
    */
	SCK_Pin=SCK;
	RST_Pin=RST;
    
}

If I leave this in the library, compiling is ok, but the TIVA freezes. I've compared it with the tiva conversation of the UTFT library line for line and I'm at a loss with this stupid easy code smile.png

I've attached the whole conversation of the basic and graph library.

 

Little example code (working):

// LCD5110_Sleep_Mode (C)2014 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a demo of sleep mode.
//
// This program requires a Nokia 5110 LCD module.
//
// It is assumed that the LCD module is connected to
// the following pins using a levelshifter to get the
// correct voltage to the module.
//      SCK  - Pin 8
//      MOSI - Pin 9
//      DC   - Pin 10
//      RST  - Pin 11
//      CS   - Pin 12
//
#include <LCD5110_Basic.h>
LCD5110 myGLCD(PA_2,PA_3,PA_4,PB_6,PB_7);
extern uint8_t SmallFont[];
extern uint8_t MediumNumbers[];

void setup()
{
  pinMode(PA_2,OUTPUT);
	pinMode(PA_3,OUTPUT);
	pinMode(PA_4,OUTPUT);
	pinMode(PB_6,OUTPUT);
	pinMode(PB_7,OUTPUT);
  myGLCD.InitLCD();
}

void loop()
{
  myGLCD.setFont(SmallFont);
  myGLCD.clrScr();
  myGLCD.print("Entering", CENTER, 0);
  myGLCD.print("Sleep Mode", CENTER, 8);
  myGLCD.print("in", CENTER, 16);
  myGLCD.print("Seconds", CENTER, 40);
  myGLCD.setFont(MediumNumbers);
  for (int s=10; s>=0; s--)
  {
    myGLCD.printNumI(s, CENTER, 24, 2, '0');
    delay(1000);
  }
  myGLCD.enableSleep();
  delay(5000);
  myGLCD.disableSleep();
  myGLCD.setFont(SmallFont);
  myGLCD.print("Awake again!", CENTER, 0);
  myGLCD.print("The screen was", CENTER, 16);
  myGLCD.print("cleared while", CENTER, 24);
  myGLCD.print("in Sleep Mode.", CENTER, 32);
  delay(5000);
}
 

Thanks 

Matthias

Attached Files

View the full article on Stellarisiti. 43oh pulls Stellarisiti Energia posts, so that members do not miss out questions. Please bear with this arrangement for now. Thanks!

Viewing all articles
Browse latest Browse all 2077

Trending Articles