Jump to content
43oh

Strange behavior pinMode/digitalWrite within library


Recommended Posts

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 :)

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

LCD5110_UTFT.zip

Link to post
Share on other sites

Dear spirilis!

Thank you for that! I thought I would go crazy, cause of that silly lines....

Everything is working yet. A need a little time for code cleanup and then I'll post the whole conversation in the "libraries" for energia!

 

Regards

Matthias

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...