Go Down

Topic: Hardware Timer Interrupts on the Due (Read 637 times) previous topic - next topic

SlaserX

Hello all,
I am working on porting some code from the Uno, and in it, it fires off a 1ms timer interrupt.
Clearly, the interrupts work different on the Due, but I can't find good solid information on it.
Can anyone point me in the direction I need to go?

(Note: I'm running lots of code simultaneously, getting proper use out the the 84MHz I have to me, so it has to interrupt) :)

Thanks!

Rufe0

Code: [Select]

const int delayPeriod = 42000000/1000; //42000000 is the "TCCLKS_TIMER_CLOCK1" clock speed / 1000 for 1ms

void setup() {
pmc_set_writeprotect(false);
pmc_enable_periph_clk((uint32_t)TC8_IRQn);
TC_Configure(TC2, 2,TC_CMR_WAVE|TC_CMR_WAVSEL_UP_RC|TC_CMR_TCCLKS_TIMER_CLOCK1);
TC_SetRC(TC2, 2, delayPeriod);

TC2->TC_CHANNEL[2].TC_IER=TC_IER_CPCS;
TC2->TC_CHANNEL[2].TC_IMR=TC_IMR_CPCS;
TC2->TC_CHANNEL[2].TC_IDR=~TC_IER_CPCS;

TC_Start(TC2, 2);
NVIC_EnableIRQ(TC8_IRQn);
}

void loop() {

}

void TC8_Handler()
{
TC_GetStatus(TC2, 2);

///// do something here

}

antodom

Hi there @SlaserX,

I have recently announced a library for using the TC modules (Timer Modules) channels of DUE's Atmel ATSAM3X8E micro-controller. You have the announce in this post:

https://forum.arduino.cc/index.php?topic=144446.msg2562995#msg2562995

The name of the library is tc_lib, and is available at: https://github.com/antodom/tc_lib

For doing what you want you have to use tc_lib action objects which abstract the use of ATSAM3X8E's TC module channels. Just have a look to the example action_test.ino that comes with the library.

If in any doubt, just tell me.
I hope it helps.
------------
antodom

Go Up