Hi,
I am doing a project with the AVR-based AT90USB1287 and I need to do some actions based on an external clock. For example I need to change the value of an I/O pin whenever I detect X clock edges.
My solution is to use timer1 (could be timer3 as well) and put the external clock input to pin T1 (PD6). I've set up TCCR1A to 0 and TCCR1B to 7 (external clock source; clock on rising edge).
The problem that I am facing is that I cannot simulate this external clock source in AVR Studio (version 4.18 ).
I've seen that I can modify the PIN values of each port, but even though I try to modify the PIN values of PD6 (T1) on a constant frequency, the counter TCNT1 doesn't increment.
A very simple code used to increment TCNT1 from an external clock might be this:
static uint16_t tmp; //start timer1 from external source (T1) TCNT1 = 0; // initial value TCCR1A = 0; // normal operation TCCR1B = 0x7; while(1) { if(TCNT1 == 0) tmp++; }
Leaving aside the fact that I am not disabling interrupts while I read TCNT1, the problem is that I cannot simulate the external clock source (i.e. TCNT1 always remains 0).
I didn't find a solution on this forum (or I wasn't able to find the corresponding post) nor on google.
Can anybody help me with this issue please? I would like to be able to simulate the external clock source as it will be a very important part of my project.
Thank you