EmbeddedRelated.com
Forums

Digital Clock with 24HR AM/PM Format

Started by ezar_shah May 24, 2007
Hi! A newbie here.I'm using MSP430F449 and Softbaugh LCD to create my
project.

; The task is, when the program starts (before any of the button is
; pressed) the LCD display will show my Student no. n my name and
; these 2 will change alternately every 3 sec.

; Max. 6 buttons and one of the button starts the program by showing
; the clock on the LCD

; Display format: HH:MM:SS

; The program can change the Hour format with a press of a button:
; HH = 0...24 and HH = 0...12(AM/PM)

; This clock can only be reset by the Hardware-Reset.As long as the
; start button being pressed it will still show my Student no.(my
; name). This means that the Clock will be displayed only when you
; release the Start button. When you choose the AM/PM format, the "AM"
; or "PM2 must be shown.

What i did was i use WDT for the clock and Basic Timer for the 3sec to
alternately change my name and Student no.

I ran the program in Simulation mode and it works just fine until i
upload it into the device. Once it reads the SetupWDT subroutine,
it jumps back to SP initialisation.

And for Basic Timer, it shows my Student no. all the time instead of
changing to my name after 3sec.

Can someone help me with this?

Beginning Microcontrollers with the MSP430

Normal behavior. WDT expiration will generate a puc to
your platform. Don't play with it. His purpose is to
reset not to be used as timer.

You should use in your design a rtc. is more accurate
then the internal CPU clock.

--- ezar_shah wrote:

> Hi! A newbie here.I'm using MSP430F449 and Softbaugh
> LCD to create my
> project.
>
> ; The task is, when the program starts (before any
> of the button is
> ; pressed) the LCD display will show my Student no.
> n my name and
> ; these 2 will change alternately every 3 sec.
>
> ; Max. 6 buttons and one of the button starts the
> program by showing
> ; the clock on the LCD
>
> ; Display format: HH:MM:SS
>
> ; The program can change the Hour format with a
> press of a button:
> ; HH = 0...24 and HH = 0...12(AM/PM)
>
> ; This clock can only be reset by the
> Hardware-Reset.As long as the
> ; start button being pressed it will still show my
> Student no.(my
> ; name). This means that the Clock will be displayed
> only when you
> ; release the Start button. When you choose the
> AM/PM format, the "AM"
> ; or "PM2 must be shown.
>
> What i did was i use WDT for the clock and Basic
> Timer for the 3sec to
> alternately change my name and Student no.
>
> I ran the program in Simulation mode and it works
> just fine until i
> upload it into the device. Once it reads the
> SetupWDT subroutine,
> it jumps back to SP initialisation.
>
> And for Basic Timer, it shows my Student no. all the
> time instead of
> changing to my name after 3sec.
>
> Can someone help me with this?
>
Best regards,

Adrian Popa

____________________________________________________________________________________
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html
I'd stay away from the real time clock for this application. No real
need to add expense to something this basic. By your description it
sounds as if you are a student and you have done some background work to
get the thing up and running. When I started I had a little trouble
with the timers as they are somewhat confusing.

The watchdog can be configured as a WDT or an interval timer on some
chips. Dig into the WDTCTL register and make sure its set up correctly.
Then have the guy sitting next to you in the lab (or your roommate...)
take a look and make sure its set up correctly. Take a look at the
users guide watchdog timer operation. If you still have trouble with
the setup post the setup routines here. Now, with all that being said,
I think it would probably be easier to set up the Timer1 as a 10mSec
heartbeat and then monitor this heart beat in the mainline code.

As for the basic timer....are you sure that the timer is actually
running?

Dan

________________________________

From: m... [mailto:m...] On Behalf
Of Adrian Popa
Sent: Thursday, May 24, 2007 3:39 PM
To: m...
Subject: Re: [msp430] Digital Clock with 24HR AM/PM Format

Normal behavior. WDT expiration will generate a puc to
your platform. Don't play with it. His purpose is to
reset not to be used as timer.

You should use in your design a rtc. is more accurate
then the internal CPU clock.

--- ezar_shah >
wrote:

> Hi! A newbie here.I'm using MSP430F449 and Softbaugh
> LCD to create my
> project.
>
> ; The task is, when the program starts (before any
> of the button is
> ; pressed) the LCD display will show my Student no.
> n my name and
> ; these 2 will change alternately every 3 sec.
>
> ; Max. 6 buttons and one of the button starts the
> program by showing
> ; the clock on the LCD
>
> ; Display format: HH:MM:SS
>
> ; The program can change the Hour format with a
> press of a button:
> ; HH = 0...24 and HH = 0...12(AM/PM)
>
> ; This clock can only be reset by the
> Hardware-Reset.As long as the
> ; start button being pressed it will still show my
> Student no.(my
> ; name). This means that the Clock will be displayed
> only when you
> ; release the Start button. When you choose the
> AM/PM format, the "AM"
> ; or "PM2 must be shown.
>
> What i did was i use WDT for the clock and Basic
> Timer for the 3sec to
> alternately change my name and Student no.
>
> I ran the program in Simulation mode and it works
> just fine until i
> upload it into the device. Once it reads the
> SetupWDT subroutine,
> it jumps back to SP initialisation.
>
> And for Basic Timer, it shows my Student no. all the
> time instead of
> changing to my name after 3sec.
>
> Can someone help me with this?
>

Best regards,

Adrian Popa

__________________________________________________________
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html
Hi Dan

I've setup the WDT as shown below:

SetupWDT mov #WDTPW+WDTCNTCL+WDTSSEL+WDTIS0,&WDTCTL ; 1000ms
bis.b #WDTIE,&IE1 ; Enable
WDT interrupt

and for the Basic Timer:

SETUPBT bis.b #BTDIV+BTIP2+BTIP1,&BTCTL
bis.b #BTIE,&IE2 ; Enable Basic Timer
Interrupt

I forgot to mention that i use Assembler.
For the setup, i refer to the header data of msp430x44x.h

And for the Basic Timer, i'm don't know how to check whether its running
or not.
I assume that once you enable the Basic Timer interrupt, it'll run.

Izzar
--- In m..., "Dan Muzzey" wrote:
>
> I'd stay away from the real time clock for this application. No real
> need to add expense to something this basic. By your description it
> sounds as if you are a student and you have done some background work
to
> get the thing up and running. When I started I had a little trouble
> with the timers as they are somewhat confusing.
>
> The watchdog can be configured as a WDT or an interval timer on some
> chips. Dig into the WDTCTL register and make sure its set up
correctly.
> Then have the guy sitting next to you in the lab (or your roommate...)
> take a look and make sure its set up correctly. Take a look at the
> users guide watchdog timer operation. If you still have trouble with
> the setup post the setup routines here. Now, with all that being
said,
> I think it would probably be easier to set up the Timer1 as a 10mSec
> heartbeat and then monitor this heart beat in the mainline code.
>
> As for the basic timer....are you sure that the timer is actually
> running?
>
> Dan
>
> ________________________________
>
> From: m... [mailto:m...] On Behalf
> Of Adrian Popa
> Sent: Thursday, May 24, 2007 3:39 PM
> To: m...
> Subject: Re: [msp430] Digital Clock with 24HR AM/PM Format
>
> Normal behavior. WDT expiration will generate a puc to
> your platform. Don't play with it. His purpose is to
> reset not to be used as timer.
>
> You should use in your design a rtc. is more accurate
> then the internal CPU clock.
>
> --- ezar_shah ezar_shah@... >
> wrote:
>
> > Hi! A newbie here.I'm using MSP430F449 and Softbaugh
> > LCD to create my
> > project.
> >
> > ; The task is, when the program starts (before any
> > of the button is
> > ; pressed) the LCD display will show my Student no.
> > n my name and
> > ; these 2 will change alternately every 3 sec.
> >
> > ; Max. 6 buttons and one of the button starts the
> > program by showing
> > ; the clock on the LCD
> >
> > ; Display format: HH:MM:SS
> >
> > ; The program can change the Hour format with a
> > press of a button:
> > ; HH = 0...24 and HH = 0...12(AM/PM)
> >
> > ; This clock can only be reset by the
> > Hardware-Reset.As long as the
> > ; start button being pressed it will still show my
> > Student no.(my
> > ; name). This means that the Clock will be displayed
> > only when you
> > ; release the Start button. When you choose the
> > AM/PM format, the "AM"
> > ; or "PM2 must be shown.
> >
> > What i did was i use WDT for the clock and Basic
> > Timer for the 3sec to
> > alternately change my name and Student no.
> >
> > I ran the program in Simulation mode and it works
> > just fine until i
> > upload it into the device. Once it reads the
> > SetupWDT subroutine,
> > it jumps back to SP initialisation.
> >
> > And for Basic Timer, it shows my Student no. all the
> > time instead of
> > changing to my name after 3sec.
> >
> > Can someone help me with this?
> >
> >
> > Best regards,
>
> Adrian Popa
>
> __________________________________________________________
> Sucker-punch spam with award-winning protection.
> Try the free Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/features_spam.html
>
>
The biggest problem students and newbies have is the ability to
break-down the problem and attack is systematically.

Organize your code so you can bring it up in stages on the real
hardware. Start with getting your clock scheme working 100% on real
hardware, then build the application around it. Otherwise, you're
going to be spinning your wheels hacking away at a complex piece of
software when your problem is quite isolated.

This organization will also help your documentation.

Stuart

--- In m..., "ezar_shah" wrote:
>
> Hi! A newbie here.I'm using MSP430F449 and Softbaugh LCD to create my
> project.
>
> ; The task is, when the program starts (before any of the button is
> ; pressed) the LCD display will show my Student no. n my name and
> ; these 2 will change alternately every 3 sec.
>
> ; Max. 6 buttons and one of the button starts the program by showing
> ; the clock on the LCD
>
> ; Display format: HH:MM:SS
>
> ; The program can change the Hour format with a press of a button:
> ; HH = 0...24 and HH = 0...12(AM/PM)
>
> ; This clock can only be reset by the Hardware-Reset.As long as the
> ; start button being pressed it will still show my Student no.(my
> ; name). This means that the Clock will be displayed only when you
> ; release the Start button. When you choose the AM/PM format, the "AM"
> ; or "PM2 must be shown.
>
> What i did was i use WDT for the clock and Basic Timer for the 3sec to
> alternately change my name and Student no.
>
> I ran the program in Simulation mode and it works just fine until i
> upload it into the device. Once it reads the SetupWDT subroutine,
> it jumps back to SP initialisation.
>
> And for Basic Timer, it shows my Student no. all the time instead of
> changing to my name after 3sec.
>
> Can someone help me with this?
>
>From the code you posted below I don't think you are setting up the WD in interval timer mode. I'm not 100% sure of that because I'm not sure what chip you used. Looking at slau049f users guide I would think you should also or in WDTTMSEL to set this into interval mode. Try starting there. Not saying this is the only thing wrong or that this is wrong (could be chip dependend). Also read through the section paying close attention to the order in which things are done.

As for the basic timer...if you didn't explicitly set it up then it is probably set wrong. Its also probably unneeded.

Unless the assingment specifically directs you to use two different clock sources I'd stick with one. Create a 10mS tick using the WDT in interval mode. Use this as a time source to base all your timing off of. A simple method of verifying the interupt is running correctly is to toggle a pin in the interupt. Look at the pin on the scope and you should see a square wave out. Once this is running everything else starts falling into place.

I've found it works better to set stuff up using the users guide. The chip has a lot of "gotcha's" that are explained in the users guide. Don't rely on the header file for anything other than to double check the name of the bit.

If you still have troubles with the interupt timer go through each bit of the set up register commenting on why each should be on or off. Somewhat tedious yes, but it should help you solve the problem yourself. It also shows you are willing to dig into stuff and try to find the answer.

________________________________

From: m... on behalf of ezar_shah
Sent: Fri 5/25/2007 5:50 AM
To: m...
Subject: [msp430] Re: Digital Clock with 24HR AM/PM Format

Hi Dan

I've setup the WDT as shown below:

SetupWDT mov #WDTPW+WDTCNTCL+WDTSSEL+WDTIS0,&WDTCTL ; 1000ms
bis.b #WDTIE,&IE1 ; Enable
WDT interrupt

and for the Basic Timer:

SETUPBT bis.b #BTDIV+BTIP2+BTIP1,&BTCTL
bis.b #BTIE,&IE2 ; Enable Basic Timer
Interrupt

I forgot to mention that i use Assembler.
For the setup, i refer to the header data of msp430x44x.h

And for the Basic Timer, i'm don't know how to check whether its running
or not.
I assume that once you enable the Basic Timer interrupt, it'll run.

Izzar

--- In m... , "Dan Muzzey" wrote:
>
> I'd stay away from the real time clock for this application. No real
> need to add expense to something this basic. By your description it
> sounds as if you are a student and you have done some background work
to
> get the thing up and running. When I started I had a little trouble
> with the timers as they are somewhat confusing.
>
> The watchdog can be configured as a WDT or an interval timer on some
> chips. Dig into the WDTCTL register and make sure its set up
correctly.
> Then have the guy sitting next to you in the lab (or your roommate...)
> take a look and make sure its set up correctly. Take a look at the
> users guide watchdog timer operation. If you still have trouble with
> the setup post the setup routines here. Now, with all that being
said,
> I think it would probably be easier to set up the Timer1 as a 10mSec
> heartbeat and then monitor this heart beat in the mainline code.
>
> As for the basic timer....are you sure that the timer is actually
> running?
>
> Dan
>
> ________________________________
>
> From: m... [mailto:m... ] On Behalf
> Of Adrian Popa
> Sent: Thursday, May 24, 2007 3:39 PM
> To: m...
> Subject: Re: [msp430] Digital Clock with 24HR AM/PM Format
>
> Normal behavior. WDT expiration will generate a puc to
> your platform. Don't play with it. His purpose is to
> reset not to be used as timer.
>
> You should use in your design a rtc. is more accurate
> then the internal CPU clock.
>
> --- ezar_shah ezar_shah@... >
> wrote:
>
> > Hi! A newbie here.I'm using MSP430F449 and Softbaugh
> > LCD to create my
> > project.
> >
> > ; The task is, when the program starts (before any
> > of the button is
> > ; pressed) the LCD display will show my Student no.
> > n my name and
> > ; these 2 will change alternately every 3 sec.
> >
> > ; Max. 6 buttons and one of the button starts the
> > program by showing
> > ; the clock on the LCD
> >
> > ; Display format: HH:MM:SS
> >
> > ; The program can change the Hour format with a
> > press of a button:
> > ; HH = 0...24 and HH = 0...12(AM/PM)
> >
> > ; This clock can only be reset by the
> > Hardware-Reset.As long as the
> > ; start button being pressed it will still show my
> > Student no.(my
> > ; name). This means that the Clock will be displayed
> > only when you
> > ; release the Start button. When you choose the
> > AM/PM format, the "AM"
> > ; or "PM2 must be shown.
> >
> > What i did was i use WDT for the clock and Basic
> > Timer for the 3sec to
> > alternately change my name and Student no.
> >
> > I ran the program in Simulation mode and it works
> > just fine until i
> > upload it into the device. Once it reads the
> > SetupWDT subroutine,
> > it jumps back to SP initialisation.
> >
> > And for Basic Timer, it shows my Student no. all the
> > time instead of
> > changing to my name after 3sec.
> >
> > Can someone help me with this?
> >
> >
> > Best regards,
>
> Adrian Popa
>
> __________________________________________________________
> Sucker-punch spam with award-winning protection.
> Try the free Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/features_spam.html
> >
>