This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Reset button remove power from Hibernation module? TM4C1294NCPDT



Edit: Scroll down, the updated code is in another later post.

hi,

Does the reset button or debugging remove power from the microcontroller?

I'm trying to debug a problem using the Hibernation module on the Connected Launchpad. I'm working on a RTC program that displays date and time on a Nokia5110 LCD. I'm using the button 1 & 2 on the launchpad to interact with the setup mode.  I have a function that sets the time and one that displays it. I'm using all local variables in functions. 

Everything works good after, I set the time in setup. But reset on the board or flashing screws it all up again.

It's like the Hibernation module is losing power or I'm programming it wrong.  

I have some cleaning up to do. but here is the code:

#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include "inc/hw_gpio.h"
#include "inc/hw_hibernate.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/hibernate.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"


static char *textMonth[12] =
{
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};

void Nokia5110_Init();
void Nokia5110_Clear();
void Nokia5110_SmallDec(unsigned short n);
void Nokia5110_OutString(char *ptr);
void SetTime();
void DisplayTime ();
void Nokia5110_SetCursor(unsigned char newX, unsigned char newY);

int main(void) {

unsigned long ui32SysClock;
struct tm sTime;


ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
HibernateEnableExpClk(ui32SysClock);
HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);
HibernateRTCEnable();

HibernateCounterMode(HIBERNATE_COUNTER_12HR); //use 12 hour AM/PM calender mode

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE,GPIO_PIN_0 | GPIO_PIN_1);
//setup internal pull up resistors page 119
GPIOPadConfigSet(GPIO_PORTJ_BASE,GPIO_PIN_0 | GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

Nokia5110_Init();
Nokia5110_Clear();

HibernateCalendarSet(&sTime);

while(1){

DisplayTime ();

if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){
SysCtlDelay(200000000); //40 million is 1 Second
if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){
SetTime();
}
}
}
}
void DisplayTime (){

struct tm sTime;
char AMPM[3] = "AM";
int lastUpdate = 100;

HibernateCalendarGet(&sTime);

if(lastUpdate == sTime.tm_sec){return;}

if(sTime.tm_hour == 0)
{
sTime.tm_hour = 12;
strcpy(AMPM, "AM");
}
else if(sTime.tm_hour == 12)
{
strcpy(AMPM, "PM");
}
else if(sTime.tm_hour > 12)
{
sTime.tm_hour -= 12;
strcpy(AMPM, "PM");
}

Nokia5110_SetCursor(0,0);
Nokia5110_OutString(" ");
Nokia5110_SetCursor(0,0);
Nokia5110_OutString(textMonth[sTime.tm_mon]);
Nokia5110_OutString(":");
Nokia5110_SmallDec(sTime.tm_mday);
Nokia5110_OutString(":20");
Nokia5110_SmallDec(sTime.tm_year - 100);
Nokia5110_SetCursor(0,1);
Nokia5110_OutString(" ");
Nokia5110_SetCursor(0,1);
Nokia5110_SmallDec(sTime.tm_hour);
Nokia5110_OutString(":");
Nokia5110_SmallDec(sTime.tm_min);
Nokia5110_OutString(":");
Nokia5110_SmallDec(sTime.tm_sec);
Nokia5110_OutString(" ");
Nokia5110_OutString(AMPM);


}

void SetTime(){

struct tm sTime;
int dayOfWeek = 0;
int hour = 1;
int minute = 0;
int dayOfMonth = 1;
int month = 0;
int year = 0;
unsigned long Check = 0;

Nokia5110_Clear();
Nokia5110_OutString(" SET TIME");
SysCtlDelay(60000000);

//---Set Year---

Nokia5110_Clear();
Nokia5110_SetCursor(2,1);
Nokia5110_OutString("SET YEAR");
Nokia5110_SetCursor(4,3);
Nokia5110_OutString("20");

while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){ //check SW1 Enter
Check = year;
if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){//read SW2 Adjust
while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
year++;
}
if (year > 30){year = 0;}

if (Check != year){
Nokia5110_SetCursor(6,3);
Nokia5110_OutString(" ");
Nokia5110_SetCursor(6,3);
}
Nokia5110_SetCursor(6,3);
Nokia5110_SmallDec(year);
}
SysCtlDelay(40000000);

//---Set Month---

Nokia5110_Clear();
Nokia5110_SetCursor(2,1);
Nokia5110_OutString("SET MONTH");

while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){ //check SW1 Enter
Check = month;
if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){//read SW2 Adjust
while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
month++;
}
if (month > 11){month = 0;}

if (Check != month){
Nokia5110_SetCursor(1,3);
Nokia5110_OutString(" ");
Nokia5110_SetCursor(1,3);
}

Nokia5110_SetCursor(1,3);
if (month == 0){Nokia5110_OutString("JANUARY");}
if (month == 1){Nokia5110_OutString("FEBRUARY");}
if (month == 2){Nokia5110_OutString("MARCH");}
if (month == 3){Nokia5110_OutString("APRIL");}
if (month == 4){Nokia5110_OutString("MAY");}
if (month == 5){Nokia5110_OutString("JUNE");}
if (month == 6){Nokia5110_OutString("JULY");}
if (month == 7){Nokia5110_OutString("AUGUST");}
if (month == 8){Nokia5110_OutString("SEPTEMBER");}
if (month == 9){Nokia5110_OutString("OCTOBER");}
if (month == 10){Nokia5110_OutString("NOVEMBER");}
if (month == 11){Nokia5110_OutString("DECEMBER");}
}
SysCtlDelay(40000000);

//---Day of the Month---

Nokia5110_Clear();
Nokia5110_SetCursor(1,1);
Nokia5110_OutString("SET DAY OF");
Nokia5110_SetCursor(1,2);
Nokia5110_OutString("THE MONTH");

while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){ //check SW1 Enter
Check = dayOfMonth;
if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){//read SW2 Adjust
while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
dayOfMonth++;
}
if (dayOfMonth > 31){dayOfMonth = 1;}

if (Check != dayOfMonth){
Nokia5110_SetCursor(5,3);
Nokia5110_OutString(" ");
Nokia5110_SetCursor(5,3);
}

Nokia5110_SetCursor(5,3);
Nokia5110_SmallDec(dayOfMonth);
}
SysCtlDelay(40000000);

//---Day of the Week---

Nokia5110_Clear();
Nokia5110_SetCursor(1,1);
Nokia5110_OutString("SET DAY OF");
Nokia5110_SetCursor(1,2);
Nokia5110_OutString("THE WEEK");

while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){ //check SW1 Enter
Check = dayOfWeek;
if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){//read SW2 Adjust
while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
dayOfWeek++;
}
if (dayOfWeek > 6){dayOfWeek = 0;}

if (Check != dayOfWeek){
Nokia5110_SetCursor(1,4);
Nokia5110_OutString(" ");
Nokia5110_SetCursor(1,4);
}
Nokia5110_SetCursor(1,4);
if (dayOfWeek == 0){Nokia5110_OutString("SUNDAY");}
if (dayOfWeek == 1){Nokia5110_OutString("MONDAY");}
if (dayOfWeek == 2){Nokia5110_OutString("TUESDAY");}
if (dayOfWeek == 3){Nokia5110_OutString("WEDNESDAY");}
if (dayOfWeek == 4){Nokia5110_OutString("THURSDAY");}
if (dayOfWeek == 5){Nokia5110_OutString("FRIDAY");}
if (dayOfWeek == 6){Nokia5110_OutString("SATURDAY");}
Nokia5110_SetCursor(1,4);
}
SysCtlDelay(40000000);

//---Hour of the Day---

Nokia5110_Clear();
Nokia5110_SetCursor(1,1);
Nokia5110_OutString("SET HOUR");

while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){ //check SW1 Enter
Check = hour;
if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){//read SW2 Adjust
while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
hour++;
}
if (hour > 23){hour = 0;}

if (Check != hour){
Nokia5110_SetCursor(5,3);
Nokia5110_OutString(" ");
Nokia5110_SetCursor(5,3);
}
Nokia5110_SetCursor(5,3);
Nokia5110_SmallDec(hour);
}
SysCtlDelay(40000000);

//---Minute of the Hour---

Nokia5110_Clear();
Nokia5110_SetCursor(1,1);
Nokia5110_OutString("SET MINUTE");

while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){ //check SW1 Enter
Check = minute;
if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){//read SW2 Adjust
while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
minute++;
}
if (minute > 59){minute = 0;}

if (Check != minute){
Nokia5110_SetCursor(5,3);
Nokia5110_OutString(" ");
Nokia5110_SetCursor(5,3);
}
Nokia5110_SetCursor(5,3);
Nokia5110_SmallDec(minute);
}
SysCtlDelay(40000000);

sTime.tm_year = 100 + year;
sTime.tm_mon = month;
sTime.tm_mday = dayOfMonth;
sTime.tm_wday = dayOfWeek;
sTime.tm_hour = hour;
sTime.tm_min = minute;

HibernateCalendarSet(&sTime);

Nokia5110_Clear();
}

I can post the Nokia5110 files If anyone wants. But I think there is any bugs in them. I use them all the time in other programs with no problems.

Thanks for any help;

Dan

  • Hi,

    The reset button does not remove the power from the micro - instead, your software is the cause of all problems:

    You do not mention if you have or not a backup battery for your hibernation module - so if you remove the power your data is lost. Also, all resets clean up the RAM memory and while you have local variables (which is neither a quality or a bad thing) a time structure with 0 content is called to set up the calendar, one line before while(1), eventually erasing everything before reading. So your program needs more tweaking - think about what is needed to do if the battery is present, hibernation is working and you weak up the micro.

    One more thing - what about debouncing the switches? don't you need such thing? can this be avoided?

    Petrei

  • By the way, if you are using a launchpad the VBAT is connected to the VCC, it's not available at all.

  • hi thanks for the reply,

    1. No battery, it's just the basic launchpad. But I looked at the schematic and it looks easy to add one.

    2. I thought there where special registers that didn't get erased in the hibernation module on reset.  If, it's using RAM. It makes sense that it would be erased. But wouldn't it get erased after leaving the setup function any ways? It is just a local variable. HibernateCalendarSet() must be saving the data somewhere else? It's just not in a safe place from a reset.

    3. I was meaning to erase struct tm sTime; in main() but forgot. I'll get rid of it.

    4. I know about the debounce on the switches. the way I have it now works pretty good. with the delay and action after the button released. timing doesn't matter in the setup anyway. It's just quick and dirty now. I ll likely change it before calling this done,

    thanks,

    dan

  • I didnt know about the </> thing. I ll use it next time.

    thanks,

    dan

  • Hi,

    Depending on your request - you should manage to display first and if the user decide it is wrong and need to be changed, then make changes and then save. 

    Take care how you manage the calendar - what the user need to enter for the year - as you have done now could be correct if the user is informed to enter only "14" instead "2014" - otherwise the calendar function may behave wrong.

    As a test program could be OK, but for user point of view needs more tweaking.

    Petrei

  • I just soldered a terminal pin onto TP11 and removed the 0 ohm resister R39. I put a jumper wire from 3.3 volt to TP11. So, VBAT never loses power. then, removed power from the MCU by removing the jumper. The time still gets screwed up after reapplying power to the MCU. I need to figure out how the store the varaibles in the hibernation module backed up registers. but why wouldn't HibernateCalendarSet() that anyways?

    Dan

  • I got it figured out. The struct being sent to HibernateCalendarSet() just needed to be a global variable. Just because I would have saved a lot of time had I seen this first before trying to figure it out. Here is the most updated code: 

    #include <stdint.h>
    #include <stdbool.h>
    #include <string.h>
    #include <time.h>
    #include "inc/hw_gpio.h"
    #include "inc/hw_hibernate.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_sysctl.h"
    #include "inc/hw_types.h"
    #include "driverlib/gpio.h"
    #include "driverlib/hibernate.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    
    static char *textMonth[12] =
    {
    		"Jan",
    		"Feb",
    		"Mar",
    		"Apr",
    		"May",
    		"Jun",
    		"Jul",
    		"Aug",
    		"Sep",
    		"Oct",
    		"Nov",
    		"Dec"
    };
    void Nokia5110_Init();
    void Nokia5110_Clear();
    void Nokia5110_SmallDec(unsigned short n);
    void Nokia5110_OutString(char *ptr);
    void SetTime();
    void DisplayTime ();
    void Nokia5110_SetCursor(unsigned char newX, unsigned char newY);
    
    struct tm sTime; //has to be a global variable
                     //to not get lost when MCU is reset
    int main(void) {
    
    	unsigned long ui32SysClock;
    
    	ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN |
    			SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
    
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
    	HibernateEnableExpClk(ui32SysClock);
    	HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE); //32 K OSC
    	HibernateRTCEnable();
    
    	HibernateCounterMode(HIBERNATE_COUNTER_12HR);
    
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
    	GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE,GPIO_PIN_0 | GPIO_PIN_1);
    	//setup internal pull up resistors page 119 of datasheet
    	GPIOPadConfigSet(GPIO_PORTJ_BASE,GPIO_PIN_0 | GPIO_PIN_1,
    			         GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    
    	Nokia5110_Init();
    	Nokia5110_Clear();
    
    	while(1){
    
    		DisplayTime ();
    
    		if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){
    			SysCtlDelay(100000000);
    			if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){
    				//if button still pressed after delay goto setTime()
    				SetTime();
    			}
    		}
    	}
    }
    void DisplayTime (){
    
    	struct tm sTime2;  // using local variable so it doesn't mess up the global
    	char AMPM[3] = "AM";
    	int lastUpdate = 100;
    
    	HibernateCalendarGet(&sTime2);
    
    	if(lastUpdate == sTime2.tm_sec){return;} //exit function if the time
    	                                         //is the same as last update
    	if(sTime2.tm_hour == 0)
    	{
    		sTime2.tm_hour = 12;
    		strcpy(AMPM, "AM");
    	}
    	else if(sTime2.tm_hour == 12)
    	{
    		strcpy(AMPM, "PM");
    	}
    	else if(sTime2.tm_hour > 12)
    	{
    		sTime2.tm_hour -= 12;
    		strcpy(AMPM, "PM");
    	}
    
    	Nokia5110_SetCursor(0,0);
    	Nokia5110_OutString("            ");
    	Nokia5110_SetCursor(0,0);
    	Nokia5110_OutString(textMonth[sTime2.tm_mon]);
    	Nokia5110_OutString(":");
    	Nokia5110_SmallDec(sTime2.tm_mday);
    	Nokia5110_OutString(":20");
    	Nokia5110_SmallDec(sTime2.tm_year - 100);
    	Nokia5110_SetCursor(0,1);
    	Nokia5110_OutString("            ");
    	Nokia5110_SetCursor(0,1);
    	Nokia5110_SmallDec(sTime2.tm_hour);
    	Nokia5110_OutString(":");
    	Nokia5110_SmallDec(sTime2.tm_min);
    	Nokia5110_OutString(":");
    	Nokia5110_SmallDec(sTime2.tm_sec);
    	Nokia5110_OutString(" ");
    	Nokia5110_OutString(AMPM);
    
    	lastUpdate = sTime2.tm_sec;
    }
    
    void SetTime(){ //uses global sTime variable
    
    	int dayOfWeek = 0;
    	int hour = 1;  //alway set as military time (24 hour day)
    	int minute = 0;
    	int dayOfMonth = 1;
    	int month = 0;
    	int year = 14;
    	unsigned long Check = 0;
    
    	Nokia5110_Clear();
    	Nokia5110_OutString(" SET TIME");
    	SysCtlDelay(30000000);
    
    	//---Set Year---
    
    	Nokia5110_Clear();
    	Nokia5110_SetCursor(2,1);
    	Nokia5110_OutString("SET YEAR");
    	Nokia5110_SetCursor(4,3);
    	Nokia5110_OutString("20");
    
    	while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){   //check SW1 Enter
    		Check = year;
    		if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){  //read SW2 Adjust
    			while  (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
    			year++;
    		}
    		if (year > 30){year = 14;} //set value between 14 - 30
    
    		if (Check != year){
    			Nokia5110_SetCursor(6,3);
    			Nokia5110_OutString("  ");
    			Nokia5110_SetCursor(6,3);
    		}
    		Nokia5110_SetCursor(6,3);
    		Nokia5110_SmallDec(year);
    	}
    	SysCtlDelay(20000000);
    
    	//---Set Month---
    
    	Nokia5110_Clear();
    	Nokia5110_SetCursor(2,1);
    	Nokia5110_OutString("SET MONTH");
    
    	while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){   //check SW1 Enter
    		Check = month;
    		if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){  //read SW2 Adjust
    			while  (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
    			month++;
    		}
    		if (month > 11){month = 0;}
    
    		if (Check != month){
    			Nokia5110_SetCursor(1,3);
    			Nokia5110_OutString("         ");
    			Nokia5110_SetCursor(1,3);
    		}
    		Nokia5110_SetCursor(1,3);
    		if (month == 0){Nokia5110_OutString("JANUARY");}
    		if (month == 1){Nokia5110_OutString("FEBRUARY");}
    		if (month == 2){Nokia5110_OutString("MARCH");}
    		if (month == 3){Nokia5110_OutString("APRIL");}
    		if (month == 4){Nokia5110_OutString("MAY");}
    		if (month == 5){Nokia5110_OutString("JUNE");}
    		if (month == 6){Nokia5110_OutString("JULY");}
    		if (month == 7){Nokia5110_OutString("AUGUST");}
    		if (month == 8){Nokia5110_OutString("SEPTEMBER");}
    		if (month == 9){Nokia5110_OutString("OCTOBER");}
    		if (month == 10){Nokia5110_OutString("NOVEMBER");}
    		if (month == 11){Nokia5110_OutString("DECEMBER");}
    	}
    	SysCtlDelay(20000000);
    
    	//---Day of the Month---
    
    	Nokia5110_Clear();
    	Nokia5110_SetCursor(1,1);
    	Nokia5110_OutString("SET DAY OF");
    	Nokia5110_SetCursor(1,2);
    	Nokia5110_OutString("THE MONTH");
    
    	while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){ //check SW1 Enter
    		Check = dayOfMonth;
    		if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){//read SW2 Adjust
    			while  (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
    			dayOfMonth++;
    		}
    		if (dayOfMonth > 31){dayOfMonth = 1;}
    
    		if (Check != dayOfMonth){
    			Nokia5110_SetCursor(5,3);
    			Nokia5110_OutString("  ");
    			Nokia5110_SetCursor(5,3);
    		}
    
    		Nokia5110_SetCursor(5,3);
    		Nokia5110_SmallDec(dayOfMonth);
    	}
    	SysCtlDelay(20000000);
    
    	//---Day of the Week---
    
    	Nokia5110_Clear();
    	Nokia5110_SetCursor(1,1);
    	Nokia5110_OutString("SET DAY OF");
    	Nokia5110_SetCursor(1,2);
    	Nokia5110_OutString("THE WEEK");
    
    	while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){   //check SW1 Enter
    		Check = dayOfWeek;
    		if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){  //read SW2 Adjust
    			while  (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
    			dayOfWeek++;
    		}
    		if (dayOfWeek > 6){dayOfWeek = 0;}
    
    		if (Check != dayOfWeek){
    			Nokia5110_SetCursor(1,4);
    			Nokia5110_OutString("         ");
    			Nokia5110_SetCursor(1,4);
    		}
    		Nokia5110_SetCursor(1,4);
    		if (dayOfWeek == 0){Nokia5110_OutString("SUNDAY");}
    		if (dayOfWeek == 1){Nokia5110_OutString("MONDAY");}
    		if (dayOfWeek == 2){Nokia5110_OutString("TUESDAY");}
    		if (dayOfWeek == 3){Nokia5110_OutString("WEDNESDAY");}
    		if (dayOfWeek == 4){Nokia5110_OutString("THURSDAY");}
    		if (dayOfWeek == 5){Nokia5110_OutString("FRIDAY");}
    		if (dayOfWeek == 6){Nokia5110_OutString("SATURDAY");}
    		Nokia5110_SetCursor(1,4);
    	}
    	SysCtlDelay(20000000);
    
    	//---Hour of the Day---
    
    	Nokia5110_Clear();
    	Nokia5110_SetCursor(1,1);
    	Nokia5110_OutString("SET HOUR");
    
    	while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){ //check SW1 Enter
    		Check = hour;
    		if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){//read SW2 Adjust
    			while  (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
    			hour++;
    		}
    		if (hour > 23){hour = 0;}  //set on 24 hour day
    
    		if (Check != hour){
    			Nokia5110_SetCursor(5,3);
    			Nokia5110_OutString("  ");
    			Nokia5110_SetCursor(5,3);
    		}
    		Nokia5110_SetCursor(5,3);
    		Nokia5110_SmallDec(hour);
    	}
    	SysCtlDelay(20000000);
    
    	//---Minute of the Hour---
    
    	Nokia5110_Clear();
    	Nokia5110_SetCursor(1,1);
    	Nokia5110_OutString("SET MINUTE");
    
    	while (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1){ //check SW1 Enter
    		Check = minute;
    		if (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){//read SW2 Adjust
    			while  (GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_1) == 0){}
    			minute++;
    		}
    		if (minute > 59){minute = 0;}
    
    		if (Check != minute){
    			Nokia5110_SetCursor(5,3);
    			Nokia5110_OutString("  ");
    			Nokia5110_SetCursor(5,3);
    		}
    		Nokia5110_SetCursor(5,3);
    		Nokia5110_SmallDec(minute);
    	}
    	SysCtlDelay(40000000);
    
    	sTime.tm_year = 100 + year; //sTime.tm_year is the time 1900 and current year.
    	sTime.tm_mon = month;
    	sTime.tm_mday = dayOfMonth;
    	sTime.tm_wday = dayOfWeek;
    	sTime.tm_hour = hour;
    	sTime.tm_min = minute;
    
    	HibernateCalendarSet(&sTime); //set global variable to  keep data safe from
    	                              //reset or power off when using a backup battery
    	Nokia5110_Clear();
    }
    
    I done with this code for now and moving on to another part of this project. It's good enough for me. 


    thanks,

    Dan

     

  • I'll link the .c and .h files for the Nokia5110. if anyone wants to see them. They're adapted to work with Tivaware and writen by a professor of an online class I took last year.

    Dan

  • Hi daniel, may I know how do the Nokia5110_SmallDec works? I am trying to adapt the code into a LCD module, your help will be much appreciated :)