View Single Post
  #5   Spotlight this post!  
Unread 23-01-2008, 17:22
pogenwurst pogenwurst is offline
Ubuntu User
AKA: Brian
FRC #2007 (Robots of the Round Table)
Team Role: Leadership
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Duluth, GA
Posts: 78
pogenwurst is on a distinguished road
Send a message via AIM to pogenwurst
Re: Second clock/timer causes red light of death

Thank you very much to everyone for your responses!

Quote:
Originally Posted by Kevin Sevcik
Are you actually calling your timer interrupt handler from the Interrupt_Handler_Low() in ifi_frc.c?
Forgive me, but I'm afraid I don't quite understand what you mean. :/

My understanding is that after calling Initialize_Timer_1() within Initialize(), the ISR for timer 1 (if enabled) should be called every time timer 1 overflows (in this case, every 25ms). Am I missing something (or was it an issue of me miscommunicating by forgetting to mention that I initialized timer 1)?

Quote:
Originally Posted by Kevin Sevcik
Also, your timer interrupt handler isn't clearing the Timer 1 Interrupt Flag.
Quote:
Originally Posted by Kevin Sevcik
Also, also, if you're preloading TMR1L and TMR1H, then you need to preload them again in your interrupt handler, or they'll start counting again from 0 instead of your preloaded value.
Do'oh! Both those points make a lot of sense.

Quote:
Originally Posted by Kevin Watson
My bet is that you just forgot to enable the timer 1 ISR in ifi_frc.h.
You bet right -- I did so in timers.h but not ifi_frc.h; I just need to uncomment "#define ENABLE_TIMER_1" in ifi_frc.h, correct?

Quote:
Originally Posted by Kevin Watson
Your code looks very good.
Thank you!

Quote:
Originally Posted by Kevin Watson
The counter variables need to be global though.
Please forgive my ignorance, but I don't understand why "extern timerSecondCount;" in teleop.c (although that will later be changed to autonomous.c) is not enough.

Quote:
Originally Posted by dcbrown
The timerSecondCount is a multibyte variable. Reading it's value needs to be protected by disabling the timer interrupt enable to avoid issues.
Nice tip! That never would have occurred to me.

On a related note, how do I distinguish between a multibyte and a single-byte variable? I'm afraid I'm quite ignorant concerning this bit and byte business.

Also, to anyone who might be able to answer, was using "volatile" in my variable declaration correct (purely out of curiosity)?

Again, thank you very much to everyone who responded; I'll modify my code ASAP. All this is very frustrating, but I'm ecstatic at how much I've been learning!