Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

ISR not exiting?

ISR not exiting?

2009-02-24 by David VanHorn

I'm using GCC.

When I comment out the first Debug_Port line, the debug pin does not go high.
When I leave it in, the debug pin goes high, but never goes low.
Am I missing something special I have to do to exit an ISR?

// Timer 0 overflow ISR
ISR(TIMER0_OVF_vect)
{
	Debug_Port |= (1 << Debug_Pin);	// High
	
	// Dec to zero timer
	if (LCD_Timer > 0)
	{
	LCD_Timer--;
	}
	
	if ((Raw_Data_Size = 0) & !(GICR & (1<< INT0))) //
	// If the summer is finished, and sampling is disabled
	{// enable sampling
		GICR  |= (1<<INT0)|(0<<INT1);	// Enable eampling
		Raw_Edge_Flag = 0;				// Looking for the start of a pulse
	}
	
	Debug_Port |= (0 << Debug_Pin);		// Low
}

-- 

"The very powerful and the very stupid have one thing in common. Instead of
altering their views to fit the facts, they alter the facts to fit their
views... which can be very uncomfortable if you happen to be one of the
facts that needs altering." Doctor Who, Face of Evil

Re: [AVR-Chat] ISR not exiting?

2009-02-24 by Charlie Heath

David,

In your code you need to do this:

    Debug_Port &= ~(1 << Debug_Pin); // Low

instead of this:

    Debug_Port |= (0 << Debug_Pin); // Low

The modifed code reads Debug_Port into a temp register, clears the Debug_Pin
bit by anding with a mask consisting of all bits set except for the bit
assigned to Debug_Pin, and then writes the temp reg back to Debug_Port.

Your version reads Debug_Port into a temp register, but doesn't change the
bit assigned to Debug_Pin since oring a zero leaves the bit unchanged, and
then writes the temp reg back to Debug_Port.

HTH,
Charlie

----- Original Message ----- 
From: "David VanHorn" <microbrix@gmail.com>
To: <AVR-Chat@yahoogroups.com>
Sent: Tuesday, February 24, 2009 12:46 PM
Subject: [AVR-Chat] ISR not exiting?


> I'm using GCC.
>
> When I comment out the first Debug_Port line, the debug pin does not go
high.
> When I leave it in, the debug pin goes high, but never goes low.
> Am I missing something special I have to do to exit an ISR?
>
> // Timer 0 overflow ISR
> ISR(TIMER0_OVF_vect)
> {
> Debug_Port |= (1 << Debug_Pin); // High
>
> // Dec to zero timer
> if (LCD_Timer > 0)
> {
> LCD_Timer--;
> }
>
> if ((Raw_Data_Size = 0) & !(GICR & (1<< INT0))) //
> // If the summer is finished, and sampling is disabled
> {// enable sampling
> GICR  |= (1<<INT0)|(0<<INT1); // Enable eampling
> Raw_Edge_Flag = 0; // Looking for the start of a pulse
> }
>
> Debug_Port |= (0 << Debug_Pin); // Low
> }
>
> -- 
>
> "The very powerful and the very stupid have one thing in common. Instead
of
Show quoted textHide quoted text
> altering their views to fit the facts, they alter the facts to fit their
> views... which can be very uncomfortable if you happen to be one of the
> facts that needs altering." Doctor Who, Face of Evil
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>

Re: [AVR-Chat] ISR not exiting?

2009-02-24 by Bill Knight

David
   In addition to the other responses, is the following what you 
intended elsewhere?

if ((Raw_Data_Size == 0) && !(GICR & (1 << INT0)))

(note usage of '==' and '&&')

You might also want to revisit the following:

GICR  |= (1<<INT0)|(0<<INT1);

It might be what you want but, for reference is equivalent to

GICR  |= (1<<INT0);

Regards
-Bill Knight
R O SoftWare


David VanHorn wrote:
Show quoted textHide quoted text
> I'm using GCC.
> 
> When I comment out the first Debug_Port line, the debug pin does not go high.
> When I leave it in, the debug pin goes high, but never goes low.
> Am I missing something special I have to do to exit an ISR?
> 
> // Timer 0 overflow ISR
> ISR(TIMER0_OVF_vect)
> {
> 	Debug_Port |= (1 << Debug_Pin);	// High
> 	
> 	// Dec to zero timer
> 	if (LCD_Timer > 0)
> 	{
> 	LCD_Timer--;
> 	}
> 	
> 	if ((Raw_Data_Size = 0) & !(GICR & (1<< INT0))) //
> 	// If the summer is finished, and sampling is disabled
> 	{// enable sampling
> 		GICR  |= (1<<INT0)|(0<<INT1);	// Enable eampling
> 		Raw_Edge_Flag = 0;				// Looking for the start of a pulse
> 	}
> 	
> 	Debug_Port |= (0 << Debug_Pin);		// Low
> }
>

Re: [AVR-Chat] ISR not exiting?

2009-02-24 by David VanHorn

On Tue, Feb 24, 2009 at 4:10 PM, Bill Knight <BillK@rosw.com> wrote:
> David
>   In addition to the other responses, is the following what you
> intended elsewhere?
>
> if ((Raw_Data_Size == 0) && !(GICR & (1 << INT0)))
>
> (note usage of '==' and '&&')
>
> You might also want to revisit the following:
>
> GICR  |= (1<<INT0)|(0<<INT1);
>
> It might be what you want but, for reference is equivalent to
>
> GICR  |= (1<<INT0);
>
> Regards
> -Bill Knight
> R O SoftWare
>
>
> David VanHorn wrote:
>> I'm using GCC.
>>
>> When I comment out the first Debug_Port line, the debug pin does not go high.
>> When I leave it in, the debug pin goes high, but never goes low.
>> Am I missing something special I have to do to exit an ISR?
>>
>> // Timer 0 overflow ISR
>> ISR(TIMER0_OVF_vect)
>> {
>>       Debug_Port |= (1 << Debug_Pin); // High
>>
>>       // Dec to zero timer
>>       if (LCD_Timer > 0)
>>       {
>>       LCD_Timer--;
>>       }
>>
>>       if ((Raw_Data_Size = 0) & !(GICR & (1<< INT0))) //
>>       // If the summer is finished, and sampling is disabled
>>       {// enable sampling
>>               GICR  |= (1<<INT0)|(0<<INT1);   // Enable eampling
>>               Raw_Edge_Flag = 0;                              // Looking for the start of a pulse
>>       }
>>
>>       Debug_Port |= (0 << Debug_Pin);         // Low
>> }
>>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>



-- 

"The very powerful and the very stupid have one thing in common. Instead of
altering their views to fit the facts, they alter the facts to fit their
views... which can be very uncomfortable if you happen to be one of the
facts that needs altering." Doctor Who, Face of Evil

Re: [AVR-Chat] ISR not exiting?

2009-02-25 by Bob Paddock

>>if ((Raw_Data_Size = 0) & !(GICR & (1<< INT0)))

> if ((Raw_Data_Size == 0) && !(GICR & (1 << INT0)))
> (note usage of '==' and '&&')

Always put the constants on the left:

(0 ==Raw_Data_Size)

then the compiler tells you
when you make the:

 (Raw_Data_Size = 0)

type errors, because you can not assign
a value to a constant.


-- 
http://www.wearablesmartsensors.com/
http://www.softwaresafety.net/
http://www.designer-iii.com/
http://www.unusualresearch.com/

Re: [AVR-Chat] ISR not exiting?

2009-02-25 by David VanHorn

On Wed, Feb 25, 2009 at 6:11 AM, Bob Paddock <bob.paddock@gmail.com> wrote:
>>>if ((Raw_Data_Size = 0) & !(GICR & (1<< INT0)))
>
>> if ((Raw_Data_Size == 0) && !(GICR & (1 << INT0)))
>> (note usage of '==' and '&&')
>
> Always put the constants on the left:
>
> (0 ==Raw_Data_Size)


Good tip!  Thanks!  :)

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.