Question regarding interrupt routine in AT90CAN128
2005-08-08 by Venkat Nagappan
Yahoo Groups archive
Index last updated: 2026-04-28 22:41 UTC
Thread
2005-08-08 by Venkat Nagappan
Hi
I have a question regarding interrupt routine in AT90CAN128 .
When I try to increment the value of a register inside the interrupt
routine , the register gives some random value .
What should i do for this. Pls. help me.
bye
c.b.vijay2005-08-09 by wbounce
Sounds like you need the volatile modifier in front of you variable declaration Ie volatile uint8_t msCount; This tells the compiler that is the variable is modified outside of the interrupt routine.
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On
Behalf Of Venkat Nagappan
Sent: Monday, August 08, 2005 11:08 AM
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] Question regarding interrupt routine in AT90CAN128
Hi
I have a question regarding interrupt routine in AT90CAN128 .
When I try to increment the value of a register inside the interrupt
routine , the register gives some random value .
What should i do for this. Pls. help me.
bye
c.b.vijay
Yahoo! Groups Links2005-08-09 by Thomas Keller
On Tue, 2005-08-09 at 09:56 -0400, wbounce wrote: > Sounds like you need the volatile modifier in front of you variable > declaration > Ie > volatile uint8_t msCount; > This tells the compiler that is the variable is modified outside of > the interrupt routine. Or simply declare the variable as a global identifier. Globally declared variables are visible in all modules/files. Which C compiler is this, anyway? tom
2005-08-10 by Brian Dean
On Tue, Aug 09, 2005 at 11:11:39AM -0500, Thomas Keller wrote: > Or simply declare the variable as a global identifier. Globally > declared variables are visible in all modules/files. That would be insufficient. The 'volatile' attribute lets the compiler know that the variable could be modified outside the compiler's realm of awareness. Thus, it should not optimize accesses to the variable by caching it's value in a register. There are other reasons to use volatile also. But the OP specifically mentioned a "register" value which leads me to believe that the problem is not a 'volatile' variable, but that something else is modifying the register outside the interrupt routine. Probably just a case of not accounting for everything that uses that particular register. > Which C compiler is this, anyway? I don't think the OP said - I actually assumed assembly since he mentioned "register" as opposed to a variable. -Brian -- Brian Dean ATmega128 based MAVRIC controllers http://www.bdmicro.com/
2005-08-10 by Venkat Nagappan
its with avr studio assembly language programming xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Thomas Keller wrote:
> On Tue, 2005-08-09 at 09:56 -0400, wbounce wrote: > > Sounds like you need the volatile modifier in front of you variable > > declaration > > Ie > > volatile uint8_t msCount; > > This tells the compiler that is the variable is modified outside of > > the interrupt routine. > > Or simply declare the variable as a global identifier. Globally > declared variables are visible in all modules/files. > > Which C compiler is this, anyway? > > tom > > > > SPONSORED LINKS > Atmel avr > <http://groups.yahoo.com/gads?t=ms&k=Atmel+avr&w1=Atmel+avr&w2=Microcontrollers&w3=Intel+microprocessors&w4=Pic+microcontrollers&w5=8085+microprocessor&c=5&s=115&.sig=UdYTrGL2FrE55fcuy5wZEQ> > Microcontrollers > <http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Atmel+avr&w2=Microcontrollers&w3=Intel+microprocessors&w4=Pic+microcontrollers&w5=8085+microprocessor&c=5&s=115&.sig=lrlEOiO4YgeS8q8wlFKMDA> > Intel microprocessors > <http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Atmel+avr&w2=Microcontrollers&w3=Intel+microprocessors&w4=Pic+microcontrollers&w5=8085+microprocessor&c=5&s=115&.sig=ukPztZmdOedN_8ChzX-5zA> > > Pic microcontrollers > <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Atmel+avr&w2=Microcontrollers&w3=Intel+microprocessors&w4=Pic+microcontrollers&w5=8085+microprocessor&c=5&s=115&.sig=ZLA3s52uCUS41MlZHTBMKg> > 8085 microprocessor > <http://groups.yahoo.com/gads?t=ms&k=8085+microprocessor&w1=Atmel+avr&w2=Microcontrollers&w3=Intel+microprocessors&w4=Pic+microcontrollers&w5=8085+microprocessor&c=5&s=115&.sig=IxZk4rgmjbtS_sw6CPxrQg> > > > > ------------------------------------------------------------------------ > YAHOO! GROUPS LINKS > > * Visit your group "AVR-Chat > <http://groups.yahoo.com/group/AVR-Chat>" on the web. > > * To unsubscribe from this group, send an email to: > AVR-Chat-unsubscribe@yahoogroups.com > <mailto:AVR-Chat-unsubscribe@yahoogroups.com?subject=Unsubscribe> > > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of > Service <http://docs.yahoo.com/info/terms/>. > > > ------------------------------------------------------------------------ >