Yahoo Groups archive

AVR-Chat

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

Thread

Interupt Ttiny

Interupt Ttiny

2009-04-20 by Guido Helmstetter

Hi from newby
In the GIMSK data page it says "activity on the pin will cause interupt even if INT0 is configured as output". 
My program  is counting to a preset number and then goes to sleep, until woken up by pushing INT0 (pullup 10K). 
 
Two thing happen when DDRB PB2 as input. then the led is not on (cause of the querie, well I like it to be on),  switch works fine goes back to the routine and to sleep etc.
When DDRB as output then it works like GIMSK was set PCIE, interupt happens on level change PB2. (PCMSK is not set). 
 
Question is : Can chip be woken up with the INT0 pin, all leds functioning. Do I have to use the RESET pin instead?
Is there a clash in the GIMSK register when all set as output.
 
This is my initialization:
 
ldi temp,1<<INT0    
out GIMSK,temp
ldi temp, 1<<CS02 | 1<<CS00   
out TCCR0B, temp
 ldi temp, 1<<ISC00   ;level change on pin
out MCUCR, temp
 
ldi temp, 0xff  
 out DDRB, temp   
 ser temp
 out PORTB,temp   ;set Port
sei


      The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer, Easier.

[Non-text portions of this message have been removed]

Re: [AVR-Chat] Interupt Ttiny

2009-04-20 by Jim Wagner

On Apr 19, 2009, at 6:18 PM, Guido Helmstetter wrote:

>
>
> Hi from newby
> In the GIMSK data page it says "activity on the pin will cause  
> interupt even if INT0 is configured as output".
> My program  is counting to a preset number and then goes to sleep,  
> until woken up by pushing INT0 (pullup 10K).
>
> Two thing happen when DDRB PB2 as input. then the led is not on  
> (cause of the querie, well I like it to be on),  switch works fine  
> goes back to the routine and to sleep etc.
> When DDRB as output then it works like GIMSK was set PCIE, interupt  
> happens on level change PB2. (PCMSK is not set).
>
> Question is : Can chip be woken up with the INT0 pin, all leds  
> functioning. Do I have to use the RESET pin instead?
> Is there a clash in the GIMSK register when all set as output.
>
> This is my initialization:
>
> ldi temp,1<<INT0
> out GIMSK,temp
> ldi temp, 1<<CS02 | 1<<CS00
> out TCCR0B, temp
>  ldi temp, 1<<ISC00   ;level change on pin
> out MCUCR, temp
>
> ldi temp, 0xff
>  out DDRB, temp
>  ser temp
>  out PORTB,temp   ;set Port
> sei
>
> The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer,  
> Easier.
>
> [Non-text portions of this message have been removed]
>
>
> 
It is basically very bad to try to apply an input (which a switch IS)  
to a pin that is set as an output!

The statement you quote refers to the fact that IF one of those pins  
has an enabled interrupt, the interrupt will be triggered even if it  
is configured as an output and you cause the output level to change by  
program action. This is NOT the case with many interrupt inputs.

Jim Wagner
Oregon Research Electronics

[Non-text portions of this message have been removed]

Re: Interupt Ttiny

2009-04-21 by s.holder123@btinternet.com

Hi

Just to throw a bit in, how you wake up from sleep also depends on the sleep mode you are, INTO can be set as a edge triggered intrerrupt (low to high, high to low) which the port change interrupts are not, the MCUCR determines the type of interrupt generated by INTO.

The reason that an interrupt can be generated even if configured as an output is a) you can software generate interrupts, b) you can use this to generate a software reset.

If you do want to generate an interrupt when the button is pressed (logic 0) then set INT0 and set the appropiate values in the MCUCR so that the interrupt is an edge triggered interrupt not a pin change.
(isc01 = 1 etc) and set the pin as an input pin. Do not set it as an output when connected to a button, this can cause a short to ground.

Call a sleep port function before going to sleep to set the ports in a non-current consuming mode(this depends on what they are connected to) see the section in the data sheet "switching between input and output" but the safe way is to set them all as inputs no pull up, leave no pins floating.

Then when you wake up the device set them back to their original state.

If you do need an led indication do it from a watchdog interrupt (watchdog can be configured to an interrupt vector or reset vector) see watchdog timer section for more information.
This will wake up the device, do what is required then go back to sleep.

Or you can put the device into idle mode, then the timer will allow you to wake up and you can poll the interrupt, but not much point setting it as an interrupt then !!.

If you do use the interrupt method , then make sure you use a software debounce routine, button bounce can cause no end of funny side effects.


Hope that helps

Regards


--- In AVR-Chat@yahoogroups.com, Guido Helmstetter <guidohelm@...> wrote:
Show quoted textHide quoted text
>
> Hi from newby
> In the GIMSK data page it says "activity on the pin will cause interupt even if INT0 is configured as output". 
> My program  is counting to a preset number and then goes to sleep, until woken up by pushing INT0 (pullup 10K). 
>  
> Two thing happen when DDRB PB2 as input. then the led is not on (cause of the querie, well I like it to be on),  switch works fine goes back to the routine and to sleep etc.
> When DDRB as output then it works like GIMSK was set PCIE, interupt happens on level change PB2. (PCMSK is not set). 
>  
> Question is : Can chip be woken up with the INT0 pin, all leds functioning. Do I have to use the RESET pin instead?
> Is there a clash in the GIMSK register when all set as output.
>  
> This is my initialization:
>  
> ldi temp,1<<INT0    
> out GIMSK,temp
> ldi temp, 1<<CS02 | 1<<CS00   
> out TCCR0B, temp
>  ldi temp, 1<<ISC00   ;level change on pin
> out MCUCR, temp
>  
> ldi temp, 0xff  
>  out DDRB, temp   
>  ser temp
>  out PORTB,temp   ;set Port
> sei
> 
> 
>       The new Internet Explorer 8 optimised for Yahoo!7: Faster, Safer, Easier.
> 
> [Non-text portions of this message have been removed]
>

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.