ATTiny2313 Timer1 output compare broken in AVR Studio ?

bugmaster_at_gmail.com
Date: 02/20/05


Date: 20 Feb 2005 00:37:51 -0800

Hi,

I am attempting to use the AVR Studio IDE to implement a simple program
for ATtiny2313, utilizing both the 8-bit timer0 and the 16-bit timer1.
I am using the latest version of AVR Studio (4.11.401). Unfortunately,
I have discovered that the output compare interrupt for timer1 is not
handled correctly by the simulator.

Here is what I did:

* Create a new project under AVR Studio, and select "Simulator" as the
platform, and "ATtiny2313" as the device.
* Write a short program to intialize timer1.
  * Set the timer to CTC mode, and set the TOP value to OCR1A
(WGM13:10==0100)
  * Set OCR1A to 5
  * Enable the output compare A interrupt in TIMSK (OCIE1A==1)
  * Write an interrupt handler routine for it, with a simple NOP
inside, and place it at the correct address in the interrupt vector
table ($0004)
* My main program enables global interrupts, and loops in an infinite
loop.

Here is what I observe in the simulator:
* All the timer registers (TIMSK, OCR1A, TCCR1x) are set correctly
* The timer counter TCNT1H:TCNT1L counts from 0 to 5, then clears back
to 0, as expected (in CTC mode)
* The flag OCF1A in TIFR is set each time the timer loops around. The
OCF1A flag is cleared during the next CPU instruction.
* And yet, my interrupt routine is never called.

I have tried setting breakpoints in my routine, using the "run to
cursor" command, or stepping through execution manually with the "step
into" button. The result is the same: the output compare A interrupt
flag is set and cleared, yet my interrupt routine is never called.

Just out of curiosity, I decided to replace "attiny2313" with
"at90s2313" as the Device under the "Debug | Select platform and
device" menu in AVR studio. When I did that, my interrupt routine
started working as expected -- i.e., it was called each time the OCF1A
flag was set.

It would appear that there is a bug in the simulator for attiny2313,
which prevents it from simulating the OCF1A interrupt properly.

I should also point out that the 8-bit timer0 does not suffer from this
problem - - both its output compare interrupts (OCF0A and OCF0B) are
raised and simulated properly.

Is anyone else experiencing this problem ? Is there a workaround ?



Relevant Pages

  • Re: [Hook out HW interrupt IRQ14 with Watcom C+DOS/32a in DOS ]
    ... It seems you're building for OS2 and DOS DPMI? ... you only need one interrupt routine and usually only for ... The callback switches modes and calls the ...
    (comp.os.msdos.programmer)
  • Re: MT8888 with 89c51
    ... There Is An Interrupt Routine In 8051 That Works In 2 Way.When ... Call Progeress Or DTMF Code Has Recieved This Routine Was Invoked.When ... Available In The Circuit Turn On And After A Pause It Turn Off Via The ...
    (comp.arch.embedded)
  • Re: Interrupt routine usage not shown by top in 8.0
    ... Interrupt routine usage not shown by top in 8.0 ... PID STATE C TIME CPU COMMAND ...
    (freebsd-current)
  • Re: Serial communication with Infineon C167 (Tasking Compiler)
    ... This because we've tried to> force both receive- and transmit-interrupts by setting those flags,> and made the interrupt routines to give out different LED-blinks on a> parallel port pin. ... > void interruptserial_TX_interrupt// Interrupt Routine TxD ... > Even parity (parity bit set on odd ...
    (comp.arch.embedded)
  • Re: 32 bit FORTH ??? Different tack!
    ... there is no advantage to making a code generator faster if the system ... I *like* being able to write interrupt handlers in Forth. ... in the interrupt routine. ... State machine driven ...
    (comp.lang.forth)