attiny13 and timer interrupt

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
inetd
Posts: 4
Joined: 07 May 2014 17:07

attiny13 and timer interrupt

#1 Post by inetd » 05 Apr 2019 18:58

I can not enable interrupt on timer overflow at attiny13.
I just copied code from timer calculator(20ms period time) and add inverting pins in interrupt section. It must be equal the pwm with 50% duty cycle. And I expected to see 50% power of light on led.
But nothing happens on pins pb0 or pb1. Leds turned off and not blinking.
I tried to set TOIE0_bit = 1 without any changes.
Code is below. This code builds without any errors or warnings. Help please. I understand that it's something my very simple mistake, but I don't know how to correct it.

void InitTimer0(){
SREG_I_bit = 1;
OCR0A = 156;
TCCR0A = 0x82;
TCCR0B |= 0x05;
OCIE0A_bit = 1;
// TOIE0_bit = 1;
}

void Timer0Overflow_ISR() org IVT_ADDR_TIM0_COMPA {
//Enter your code here
PORTB0_bit = ~PORTB0_bit;
PORTB1_bit = ~PORTB1_bit;
}

void main() {

DDB1_bit = 1;
DDB0_bit = 1;

InitTimer0();

while (1)
{
};
}
Easy Mx Pro v7 for STM32

inetd
Posts: 4
Joined: 07 May 2014 17:07

Re: attiny13 and timer interrupt

#2 Post by inetd » 08 Apr 2019 13:17

Got it.
Need to set COM0A1 and COM0A0 to zeros for normal port operation.
So, TCCR0A must be changed to 0x2 in code generated from Timer Calculator.
Easy Mx Pro v7 for STM32

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: attiny13 and timer interrupt

#3 Post by jovana.medakovic » 09 Apr 2019 10:45

Hello,

I'm glad that you solved your problem.
I will forward this bug to our developer team.

I apologize for the inconvenience.

Kind regards,
Jovana

Post Reply

Return to “mikroC PRO for AVR General”