Yahoo Groups archive

AVR-Chat

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

Thread

int 0 problem

int 0 problem

2009-03-30 by Brian

I have asked this on the codevision site also but wondering if anyone here could help.

I am using a mega16 Int 0 with an encoder, no sleep, WDT or other special items.
For each detent of the encoder the input to the int 0 goes from 5 - 0.5 - 5 -
0.5 and so on, like it is designed to do. I have set the MCUCR to 0x01 for any
change, but it only responds to a negative change, so I only get an interrupt
every 2 detents of the encoder, 5 to 0.5 change. Other than this the whole
program works. I have even tried another chip. I have even tried disabling
intrupts upon entering the intrupt and enabling it with exiting.

Why am I only getting a negative change interrupt?
Is there anything that would interfer with the MCUCR to change the level change
interrupt settings to only negative change?

If someone could help off forum would be great! (my code is kinda messy since I
am a biginner)

Brian

Re: int 0 problem

2009-03-30 by stevech11

I hope I'm mistaken, but I recall that the older mega's lacked the "pin change" interrupt capability. This has a register where you enable interrupts for a change in state on a given pin.
Look at the PCICR register explanation for the mega168. I don't think the mega16 has that.  

--- In AVR-Chat@yahoogroups.com, "Brian" <blue_eagle74@...> wrote:
Show quoted textHide quoted text
>
> I have asked this on the codevision site also but wondering if anyone here could help.
> 
> I am using a mega16 Int 0 with an encoder, no sleep, WDT or other special items.
> For each detent of the encoder the input to the int 0 goes from 5 - 0.5 - 5 -
> 0.5 and so on, like it is designed to do. I have set the MCUCR to 0x01 for any
> change, but it only responds to a negative change, so I only get an interrupt
> every 2 detents of the encoder, 5 to 0.5 change. Other than this the whole
> program works. I have even tried another chip. I have even tried disabling
> intrupts upon entering the intrupt and enabling it with exiting.
> 
> Why am I only getting a negative change interrupt?
> Is there anything that would interfer with the MCUCR to change the level change
> interrupt settings to only negative change?
> 
> If someone could help off forum would be great! (my code is kinda messy since I
> am a biginner)
> 
> Brian
>

Re: int 0 problem

2009-03-30 by s.holder123@btinternet.com

How are you writing to the MCUCR ? the default setting for the interrupt pins is low level detect (iscx1 = 0, iscx0 = 0), sounds like you are not actually setting the required value in the MCUCR, can you verify that the value is as you think it is.

Regards

--- In AVR-Chat@yahoogroups.com, "Brian" <blue_eagle74@...> wrote:
Show quoted textHide quoted text
>
> I have asked this on the codevision site also but wondering if anyone here could help.
> 
> I am using a mega16 Int 0 with an encoder, no sleep, WDT or other special items.
> For each detent of the encoder the input to the int 0 goes from 5 - 0.5 - 5 -
> 0.5 and so on, like it is designed to do. I have set the MCUCR to 0x01 for any
> change, but it only responds to a negative change, so I only get an interrupt
> every 2 detents of the encoder, 5 to 0.5 change. Other than this the whole
> program works. I have even tried another chip. I have even tried disabling
> intrupts upon entering the intrupt and enabling it with exiting.
> 
> Why am I only getting a negative change interrupt?
> Is there anything that would interfer with the MCUCR to change the level change
> interrupt settings to only negative change?
> 
> If someone could help off forum would be great! (my code is kinda messy since I
> am a biginner)
> 
> Brian
>

Re: int 0 problem

2009-03-30 by Brian

The mega16 does have level change for int0, page 67. I haven't come across anything that says this is not true. I'll have to look at my code better.

Brian

--- In AVR-Chat@yahoogroups.com, "stevech11" <childresss@...> wrote:
Show quoted textHide quoted text
>
> I hope I'm mistaken, but I recall that the older mega's lacked the "pin change" interrupt capability. This has a register where you enable interrupts for a change in state on a given pin.
> Look at the PCICR register explanation for the mega168. I don't think the mega16 has that.

Re: int 0 problem

2009-03-30 by Brian

I set the following:

GICR = 0x40;   //for int0 
MCUCR = 0x01;  //int for logic change

//enable global int
#asm ("sei")

Not sure how to verify if everything is set. Still working with/learning the Studio4 debugger.

Brian


--- In AVR-Chat@yahoogroups.com, "s.holder123@..." <s.holder123@...> wrote:
Show quoted textHide quoted text
>
> How are you writing to the MCUCR ? the default setting for the interrupt pins is low level detect (iscx1 = 0, iscx0 = 0), sounds like you are not actually setting the required value in the MCUCR, can you verify that the value is as you think it is.
> 
> Regards

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.