void setup(){
pinMode(13,OUTPUT);
startTimer(TC1, 0, TC3_IRQn, 4); //TC1 channel 0, the IRQ for that channel and the desired frequency
}
void loop(){
}
Could someone explain this code to me line by line?
And answer the following questions:
How many interrupt levels are available in the Arduino Due? Why?
2.How many independent timers are available in the Arduino Due? Why?
3.How can the timers be connected to the interrupt levels? Why?
4.Can you vary the blinking frequency in this sketch? Why and How?
5.Can you use a different timer and channel? Why and How?
If you can explain those code line by line how this code work first that will be best, because I cannot understand those code in this moment.
Very, very grateful for this.
The Arduino Due timers are documented in the Atmel SAM3X8E ARM Cortex-M3 CPU documentation.
The code in startTimer() is boilerplate and will serve you well as is.
There are 9 timers handled by three “timer counters” TCs: TC0, TC1, TC2.
Each Timer Counter (TC) is responsible for 3 “channels” these are each independent timers with independent ISRs.
The ISRs (interrupt service routines) are named:
TC0_IRQn, TC1_IRQn, …, TC8_IRQn
The 0…8 in the names is TC*3+channel
EDIT: In the handler, this line: TC_GetStatus(, );
is necessary to re-enable the timer interrupt. You will not get any further calls on this interrupt if this is not done.
StanO8:
The Arduino Due timers are documented in the Atmel SAM3X8E ARM Cortex-M3 CPU documentation.
The code in startTimer() is boilerplate and will serve you well as is.
There are 9 timers handled by three “timer counters” TCs: TC0, TC1, TC2.
Each Timer Counter (TC) is responsible for 3 “channels” these are each independent timers with independent ISRs.
The ISRs (interrupt service routines) are named:
TC0_IRQn, TC1_IRQn, …, TC8_IRQn
The 0…8 in the names is TC*3+channel
EDIT: In the handler, this line: TC_GetStatus(, );
is necessary to re-enable the timer interrupt. You will not get any further calls on this interrupt if this is not done.
HTH,
Stan
Hi Stan,
Very thank you for your answer. Now I understand more of it. Is there any explanation of this code in the documentation? Can you give a link to that documentation? If you have time, please tell me more about this code and how TC and ISR work.
StanO8:
The Arduino Due timers are documented in the Atmel SAM3X8E ARM Cortex-M3 CPU documentation.
The code in startTimer() is boilerplate and will serve you well as is.
There are 9 timers handled by three “timer counters” TCs: TC0, TC1, TC2.
Each Timer Counter (TC) is responsible for 3 “channels” these are each independent timers with independent ISRs.
The ISRs (interrupt service routines) are named:
TC0_IRQn, TC1_IRQn, …, TC8_IRQn
The 0…8 in the names is TC*3+channel
EDIT: In the handler, this line: TC_GetStatus(, );
is necessary to re-enable the timer interrupt. You will not get any further calls on this interrupt if this is not done.
HTH,
Stan
I don’t know which section is about my questions? Could you point me out;)