chipKIT® Development Platform

Inspired by Arduino™

Internal Timer Compare Match Interrupts for Chipkit Max32?

Created Mon, 19 Nov 2012 17:35:29 +0000 by RoboNegro


RoboNegro

Mon, 19 Nov 2012 17:35:29 +0000

Greetings all,

Does the ChipKit Max32 have internal timer compare match interrupts? If so, does anyone have sample code for this? I have code for the ArduinoMega that looks like:

void setup()
{
    // initialize Timer5
    cli();          // disable global interrupts
    TCCR5A = 0;     // set entire TCCR1A register to 0
    TCCR5B = 0;     // same for TCCR1B
 
    // set compare match register to desired timer count:
    //80 = 200 Hz
    OCR5A = 80;

    // turn on CTC mode:
    TCCR5B |= (1 << WGM52);

    // Set CS50, CS51, CS52 bits for prescaler value: 1024
    TCCR5B |= (1 << CS50);
    TCCR5B |= (0 << CS51);
    TCCR5B |= (1 << CS52);

    // enable timer compare interrupt:
    TIMSK5 |= (1 << OCIE5A);

    sei(); // enable global interrupts

}

I would like to adapt this code to the ChipKit.

Thanks


rasmadrak

Tue, 20 Nov 2012 22:48:53 +0000

Does this thread help? :)

http://www.chipkit.org/forum/viewtopic.php?f=7&t=2098


RoboNegro

Tue, 27 Nov 2012 02:27:03 +0000

Thank you rasmadrak, this thread does help. However I was hoping to do it by using compare match interrupts. Do you know of any threads that deal with this?