Hi,
I am trying to make ATTiny13A Roomba controller, mainly virtual wall. To save power as much as possible I would like to use sleep modes extensively. ATTiny13A has only one timer/counter I use both for generating 38kHz signal modulation and for timing of the signal. The timer generates interrupt about every 26 us or 126 CPU cycles. I want to count the interrupts (38 are 1 ms) and put processor to idle in meantime (active state is about 1mA but idle only 0.2mA according to the datasheet). The problem is how to use the the interrupts.
ISR (TIM0_COMPA_vect) {
}
generates quite long code according to Atmel studio's disassembly even with maximum optimization:
00000006 RJMP PC+0x0013 Relative jump
...
00000019 PUSH R1 Push register on stack
0000001A PUSH R0 Push register on stack
0000001B IN R0,0x3F In from I/O location
0000001C PUSH R0 Push register on stack
0000001D CLR R1 Clear Register
0000001E POP R0 Pop register from stack
0000001F OUT 0x3F,R0 Out to I/O location
00000020 POP R0 Pop register from stack
00000021 POP R1 Pop register from stack
00000022 RETI Interrupt return
It saves registers R1 and R0 and SREG (system register) on stack, clears R1(why?) and then restores them all from the stack. I think it is quite pointless and it takes 17 out of 126 cycles when the CPU should be sleeping. I think the RETI instruction could be in place of the Relative jump instruction at address 0x00006 saving another time spend for unnecessary jump to 0x00019.
But I don't know how to force the Atmel studio to generate output this way. Or does it have a good reason to make so much more code?
Thanks
EDIT: EMPTY_INTERRUPT(TIM0_COMPA_vect) generates
00000006 RJMP PC+0x0013 Relative jump
...
00000019 RETI Interrupt return
But how could I get
00000006 RETI Interrupt return
this code?