Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

CTC not working with external T0/T1 signals in Arduino UNO and ATmega328P

2 posters

Go down  Message [Page 1 of 1]

Bens

Bens

Hi, I think there is a bug in Arduino UNO and ATmega328P when using Timers/Counters 0 and 1 in CTC mode with external input on T0/T1: it counts from 0 to 1 and then it stops working.
I tested the code on real hardware and it works fine.
Furthermore, all other modes (Normal and PWM) of the simulator are working properly.



Last edited by arcachofo on Wed Mar 23, 2022 10:13 am; edited 1 time in total (Reason for editing : Mark as solved (green color).)

arcachofo

arcachofo

Hi.
Which version are you using?

Also if you have a simple circuit and code to test it would be helpful.

Bens

Bens

Hi, I'm using version 0.4.15.

This is the sample code:
Code:
void setup(){
   pinMode(4,INPUT_PULLUP);

   TCCR0A = 0b00000010;
   TCCR0B = 0b00000110;
   
   OCR0A = 20;
   
   Serial.begin(9600);
}

void loop(){
   Serial.println(TCNT0);
}

CTC not working with external T0/T1 signals in Arduino UNO and ATmega328P Source11


It should count up to 20 on falling edge of pin 4 and then reset. If you use the internal clock with prescaler instead it counts regularly.

arcachofo likes this post

arcachofo

arcachofo

Issue solved at Rev 275.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum