Forums

8051 Timer 0, Mode 0

Started by Neil Cherry September 9, 2006
I'm losing my mind with the timer and I can't find out what I'm doing
wrong. I have an 8051 (Atmel 89C2051 really), Xtal = 11.059200 MHz and
a DS1232 (watchdog chip). What I need to do is to pulse (active low)
the strobe line on the DS1232 to keep the 8051 from getting reset. My
understanding of the timer is 1/(XTAL/12) = 1.085 us per tic. If I run
timer 0 in mode 1 (16 bit) it will interrupt every 71.113ms (max). If
I wait for 2 interrupts (I need between 62.5ms and 250ms before a
reset can occur) I can pulse the strobe (1-0-1) and I should be happy.
Does the above sound correct or do I have a hole in my logic?  If the
above sounds correct I can post my code to see if I'm doing something
wrong there.

Thanks

-- 
Linux Home Automation         Neil Cherry       ncherry@linuxha.com
http://www.linuxha.com/                         Main site
http://linuxha.blogspot.com/                    My HA Blog
http://home.comcast.net/~ncherry/               Backup site
Neil Cherry wrote:
> I'm losing my mind with the timer and I can't find out what I'm doing > wrong. I have an 8051 (Atmel 89C2051 really), Xtal = 11.059200 MHz and > a DS1232 (watchdog chip). What I need to do is to pulse (active low) > the strobe line on the DS1232 to keep the 8051 from getting reset. My > understanding of the timer is 1/(XTAL/12) = 1.085 us per tic. If I run > timer 0 in mode 1 (16 bit) it will interrupt every 71.113ms (max). If > I wait for 2 interrupts (I need between 62.5ms and 250ms before a > reset can occur) I can pulse the strobe (1-0-1) and I should be happy. > Does the above sound correct or do I have a hole in my logic? If the > above sounds correct I can post my code to see if I'm doing something > wrong there.
What exactly is "wrong"? Are you getting the timer interrupts, and outputting a strobe to the DS1232? If so, what is the time between strobes, and the "on" (low) time? You talk about waiting for 2 interrupts. If you are strobing the DS1232 every 142ms you are outside the minimum required timing for the chip, which is 62.5ms (for TD grounded, which apparently is your situation based on your figures of 62.5ms and 250ms).
On 9 Sep 2006 10:32:13 -0700, Mike Silva wrote:
> > Neil Cherry wrote: >> I'm losing my mind with the timer and I can't find out what I'm doing >> wrong. I have an 8051 (Atmel 89C2051 really), Xtal = 11.059200 MHz and >> a DS1232 (watchdog chip). What I need to do is to pulse (active low) >> the strobe line on the DS1232 to keep the 8051 from getting reset. My >> understanding of the timer is 1/(XTAL/12) = 1.085 us per tic. If I run >> timer 0 in mode 1 (16 bit) it will interrupt every 71.113ms (max). If >> I wait for 2 interrupts (I need between 62.5ms and 250ms before a >> reset can occur) I can pulse the strobe (1-0-1) and I should be happy. >> Does the above sound correct or do I have a hole in my logic? If the >> above sounds correct I can post my code to see if I'm doing something >> wrong there. > > What exactly is "wrong"? Are you getting the timer interrupts, and > outputting a strobe to the DS1232? If so, what is the time between > strobes, and the "on" (low) time? You talk about waiting for 2 > interrupts. If you are strobing the DS1232 every 142ms you are outside > the minimum required timing for the chip, which is 62.5ms (for TD > grounded, which apparently is your situation based on your figures of > 62.5ms and 250ms).
Oh, that would be a good thing for me to describe. I can't watch the time interval (no scope). I have a volt meter which gives frequency but I doubt it's doing me much good (say 42KHz). The basic problem is that the chip is reseting. I see the start up message approximately every second. It looks like I'm getting no interrupt. If I run the 8051 w/o the DS1232 I can manually reset it and the rest of the program runs OK. I guess I could fall back on 'print' statements to see if the interrupt is being run (I also have RS232 which is working w/o interrupts at this time. -- Linux Home Automation Neil Cherry ncherry@linuxha.com http://www.linuxha.com/ Main site http://linuxha.blogspot.com/ My HA Blog http://home.comcast.net/~ncherry/ Backup site
Neil Cherry wrote:
> On 9 Sep 2006 10:32:13 -0700, Mike Silva wrote: > > > > Neil Cherry wrote: > >> I'm losing my mind with the timer and I can't find out what I'm doing > >> wrong. I have an 8051 (Atmel 89C2051 really), Xtal = 11.059200 MHz and > >> a DS1232 (watchdog chip). What I need to do is to pulse (active low) > >> the strobe line on the DS1232 to keep the 8051 from getting reset. My > >> understanding of the timer is 1/(XTAL/12) = 1.085 us per tic. If I run > >> timer 0 in mode 1 (16 bit) it will interrupt every 71.113ms (max). If > >> I wait for 2 interrupts (I need between 62.5ms and 250ms before a > >> reset can occur) I can pulse the strobe (1-0-1) and I should be happy. > >> Does the above sound correct or do I have a hole in my logic? If the > >> above sounds correct I can post my code to see if I'm doing something > >> wrong there. > > > > What exactly is "wrong"? Are you getting the timer interrupts, and > > outputting a strobe to the DS1232? If so, what is the time between > > strobes, and the "on" (low) time? You talk about waiting for 2 > > interrupts. If you are strobing the DS1232 every 142ms you are outside > > the minimum required timing for the chip, which is 62.5ms (for TD > > grounded, which apparently is your situation based on your figures of > > 62.5ms and 250ms). > > Oh, that would be a good thing for me to describe. I can't watch the > time interval (no scope). I have a volt meter which gives frequency > but I doubt it's doing me much good (say 42KHz). The basic problem is > that the chip is reseting. I see the start up message approximately > every second. It looks like I'm getting no interrupt. If I run the > 8051 w/o the DS1232 I can manually reset it and the rest of the > program runs OK. I guess I could fall back on 'print' statements to > see if the interrupt is being run (I also have RS232 which is working > w/o interrupts at this time.
If you have a two extra I/O lines, connect some LEDs to them (you might need to buffer them). Toggle one in the interrupt routine, and toggle the other every time you do a high-to-low transition out to the DS1232. By toggling you'll get square waves that you can actually see at these frequencies. You'll be able to tell if your interrupt is being serviced, and what your strobe rate to the DS1232 is. Again, if you're waiting 142ms between strobes you're out of spec for the part -- you need to guarantee a strobe every 62.5ms. And be sure and save up for a scope or logic analyser of some sort. :)
Neil Cherry wrote:
> On 9 Sep 2006 10:32:13 -0700, Mike Silva wrote: >
> Oh, that would be a good thing for me to describe. I can't watch the > time interval (no scope). I have a volt meter which gives frequency > but I doubt it's doing me much good (say 42KHz). The basic problem is > that the chip is reseting. I see the start up message approximately > every second. It looks like I'm getting no interrupt. If I run the > 8051 w/o the DS1232 I can manually reset it and the rest of the > program runs OK. I guess I could fall back on 'print' statements to > see if the interrupt is being run (I also have RS232 which is working > w/o interrupts at this time. >
do you have enabled the timer0 interrupt ? do you have enabled the general interrupt enable ? do you have enabled the timer ( is the timer running ? ) ? two leds and a 74hc00 can be used to build a simple logic tester
Neil Cherry <njc@cookie.uucp> wrote:
> I'm losing my mind with the timer and I can't find out what I'm doing > wrong. I have an 8051 (Atmel 89C2051 really), Xtal = 11.059200 MHz and > a DS1232 (watchdog chip). What I need to do is to pulse (active low) > the strobe line on the DS1232 to keep the 8051 from getting reset.
Setting aside your problems with wrapping your head around how to steer a timer: petting the watchdog is no job for a timer. You want to inform the watchdog that your main program still runs, not that some timer survived a total crash of program. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
On 9 Sep 2006 19:49:53 GMT, in comp.arch.embedded Hans-Bernhard
Broeker <broeker@physik.rwth-aachen.de> wrote:

>Neil Cherry <njc@cookie.uucp> wrote: >> I'm losing my mind with the timer and I can't find out what I'm doing >> wrong. I have an 8051 (Atmel 89C2051 really), Xtal = 11.059200 MHz and >> a DS1232 (watchdog chip). What I need to do is to pulse (active low) >> the strobe line on the DS1232 to keep the 8051 from getting reset. > >Setting aside your problems with wrapping your head around how to >steer a timer: petting the watchdog is no job for a timer. You want >to inform the watchdog that your main program still runs, not that >some timer survived a total crash of program.
Ah, I remember hearing of a 805x crashing, but the timer kept working, so it did not reset, which tickled the WD. Is this what you meant? ISTR Jack Gannsle having some good stuff on his site martin
martin griffith <mart_in_medina@yahoo.esxxx> wrote:
> On 9 Sep 2006 19:49:53 GMT, in comp.arch.embedded Hans-Bernhard > Broeker <broeker@physik.rwth-aachen.de> wrote:
> >Neil Cherry <njc@cookie.uucp> wrote: > >> I'm losing my mind with the timer and I can't find out what I'm doing > >> wrong. I have an 8051 (Atmel 89C2051 really), Xtal = 11.059200 MHz and > >> a DS1232 (watchdog chip). What I need to do is to pulse (active low) > >> the strobe line on the DS1232 to keep the 8051 from getting reset. > > > >Setting aside your problems with wrapping your head around how to > >steer a timer: petting the watchdog is no job for a timer. You want > >to inform the watchdog that your main program still runs, not that > >some timer survived a total crash of program.
> Ah, I remember hearing of a 805x crashing, but the timer kept working, > so it did not reset, which tickled the WD. Is this what you meant?
Not quite. You have the last two items the wrong way round. The problematic case is this: the main app crashes (e.g. got stuck in an endless loop waiting for some event that can't happen), but the timer interrupts kept working, which keeps tickling the 'dog, so the CPU never gets reset. A setup like that wastes any money, time and board space spent on the WD for no effect. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
Neil Cherry wrote:
> > Oh, that would be a good thing for me to describe. I can't watch the > time interval (no scope). I have a volt meter which gives frequency > but I doubt it's doing me much good (say 42KHz). The basic problem is > that the chip is reseting. I see the start up message approximately > every second. It looks like I'm getting no interrupt. If I run the > 8051 w/o the DS1232 I can manually reset it and the rest of the > program runs OK. I guess I could fall back on 'print' statements to > see if the interrupt is being run (I also have RS232 which is working > w/o interrupts at this time.
If you have a Frequency Multimeter, then simply toggle a pin in the interrupt, and remove the 1232 reset line, while you are testing. That tells you both that the INT is alive, and you can easily calculate what the INT rate is ( half cycle = int time ). Of course, you do realise that using a timer interrupt to ping a watchdog, will miss a whole raft of possible system failures ? :) -jg
On Sun, 10 Sep 2006 09:26:35 +1200, Jim Granville wrote:
> Neil Cherry wrote: >> >> Oh, that would be a good thing for me to describe. I can't watch the >> time interval (no scope). I have a volt meter which gives frequency >> but I doubt it's doing me much good (say 42KHz). The basic problem is >> that the chip is reseting. I see the start up message approximately >> every second. It looks like I'm getting no interrupt. If I run the >> 8051 w/o the DS1232 I can manually reset it and the rest of the >> program runs OK. I guess I could fall back on 'print' statements to >> see if the interrupt is being run (I also have RS232 which is working >> w/o interrupts at this time. > > If you have a Frequency Multimeter, then simply toggle a pin in the > interrupt, and remove the 1232 reset line, while you are testing. > That tells you both that the INT is alive, and you can easily > calculate what the INT rate is ( half cycle = int time ).
This is what I have but the battery is getting low and I'm not sure it working properly. I'll get a new battery tomorrow and remove that doubt.
> Of course, you do realise that using a timer interrupt to ping a > watchdog, will miss a whole raft of possible system failures ? :)
Actually yes but I first need to resolve the timer issue before I can attack that code. :-) I had step back to basics to find the problem. -- Linux Home Automation Neil Cherry ncherry@linuxha.com http://www.linuxha.com/ Main site http://linuxha.blogspot.com/ My HA Blog http://home.comcast.net/~ncherry/ Backup site