Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Help with using interrupts and ATtiny13.

2005-08-05 by Dennis Clark

I've written for the Tiny12, not the 13 and I too simply .ORG at the 
address that I'm putting the ISR jump.  After all, you are the one 
setting the IRQ bits, so you know exactly what is happening.  It is true 
that "good" practice would be to put reti instructions there, or even a 
jump to a generic "do nothing" ISR, but the code that I've written 
hasn't run afoul of "rogue IRQs" yet... (knock on wood)

DLC

Zack Widup wrote:
> On Thu, 4 Aug 2005, Kevin Laborda wrote:
> 
> 
>>First, I use AVR Assembly.  The thing that confuses me is when initiliazing the vector table how do I "skip" the vectors I don't want.  Isn't the order important when listing the interrupts. Example code:
>>
>> .ORG 0000 ; Address is zero
>>    RJMP Start ; The reset-vector on Address 0000
>>    RJMP IService ; 0001: first Int-Vector, INT0 service routine
>>[...] here other vectors 
>>
>>if I don't want the interrupt at the 000x location do I use reti? 
>>From tn13def.inc:
>>
>>;**** Interrupt Vectors ****  
>>.equ INT0addr      =$001 ;External Interrupt0
>>.equ PCINT0addr    =$002 ;Pin Change Interrupt0
>>.equ TIM0_OVF0addr      =$003 ;Overflow0 Interrupt 
>>.equ EE_RDYaddr      =$004 ;EEPROM write complete
>>.equ ANA_COMPaddr =$005 ;Analog Comparator Interrupt 
>>.equ TIM0_COMPAaddr      =$006 ;Timer/Counter0 Compare Match A  
>>.equ TIM0_COMPBaddr    =$007 ;Timer/Counter0 Compare Match B  
>>.equ WDTaddr       =$008 ;Watchdog Timeout
>>.equ    ADCaddr      =$009 ;ADC Conversion Complete Handle
>>
>>So, after Reset ($000?), I'd have the INT0addr followed by PCINT0addr etc.  If I only want reset then the Overflow0 Interrupt would I do
>>
>>.ORG 0000
>>  RJMP Reset
>>  RETI
>>  RJMP Timer
>>  RETI
>>  RETI
>>  RETI
>>  RETI
>>  RETI 
>>
>>followed by initializing the stack and timer/prescaler in the Reset label code section?
>>
> 
> 
> You can do it that way, but I assume if I am not planning on using a given 
> interrupt, it doesn't matter what is in that vector location.  It hasn't 
> gotten me into troble yet (fingers crossed!).  What I usually do is:
> 
>  .ORG 0000
>    RJMP Reset
>  .ORG 0003  
>    RJMP Timer
>  .ORG 0009
>    RJMP ADCSVC
> 
> That way I only write code for the interrupts I'm using.
> 
> 
> 
>>Also would the following work for generic stack initialization (for what I need)?
>>
>>.def TEMP = r16
>>[...]
>>Reset:
>>ldi TEMP,low(RAMEND) ; Set stackptr to ram end
>>out SPL,TEMP
>>ldi  TEMP, high(RAMEND)
>>out  SPH, TEMP
>>[ Timer0 initialization]
>>sei
>>
>>or does the ATtiny13 require something else?
>>
>>Thanks,
>>
>>Kevin
> 
> 
> Not sure about the ATtiny13 as I haven't used that one yet, but it should 
> work with ATmega8, ATmega16, etc.
> 
> Zack
> 

-- 
---------------------------------------
Dennis Clark    TTT Enterprises
---------------------------------------

Attachments

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.