chipKIT® Development Platform

Inspired by Arduino™

Question about converting Interrupts between ChipKit/Arduino

Created Wed, 25 Jul 2012 00:48:36 +0000 by ricklon


Wed, 25 Jul 2012 00:48:36 +0000

I've been looking at the Adafruit GPS library, and it has support added for support HardwareSerial.

Which is great for the ChipKit Uno32 and Max32 boards. The one issue is that it is using interrupts in the example code. These aren't compatible with ChipKit.

Has anyone written an article on converting interrupts from Arduino to ChipKit?

Any suggestions for converting this code to ChipKit interrupts?

// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
  char c =;
  // if you want to debug, this is a good time to do it!
  if (GPSECHO)
    if (c) UDR0 = c;  
    // writing direct to UDR0 is much much faster than Serial.print 
    // but only one character can be written at a time. 

void useInterrupt(boolean v) {
  if (v) {
    // Timer0 is already used for millis() - we'll just interrupt somewhere
    // in the middle and call the "Compare A" function above
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else {
    // do not call the interrupt function COMPA anymore
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;

Thanks, --Rick