chipKIT® Development Platform

Inspired by Arduino™

Max32 Input Capture

Created Thu, 27 Jun 2013 05:49:26 +0000 by rockier


rockier

Thu, 27 Jun 2013 05:49:26 +0000

Can someone tell me why in this code that the IC1 does not trigger the ISR code. I am puting a PWM on chipkit pin 48. If I check the IC1 in the loop function I get data back.

#include <plib.h>

int LED = 13;
volatile unsigned int wPwm;

void setup()
{
  Serial.begin(9600);
  mIC1ClearIntFlag();

  CloseTimer2();
  OpenTimer2(T2_ON | T2_IDLE_CON | T2_GATE_OFF | T2_PS_1_1 | T2_32BIT_MODE_OFF | T2_SOURCE_INT, 4000);
  
  OpenCapture1(IC_ON | IC_IDLE_CON | IC_TIMER2_SRC | IC_INT_1CAPTURE | IC_SP_EVERY_EDGE | IC_FEDGE_RISE );
}

void loop()
{
}

extern "C"
{
  
    void __ISR(_INPUT_CAPTURE_1_VECTOR, ipl2) InputCapture_Handler(void)
    {
      if(digitalRead(48) == HIGH)
      {
        mIC1ClearIntFlag();  // Clear interrupt flag
        wPwm = mIC1ReadCapture();
      }
      else
      {
        wPwm = mIC1ReadCapture();
      }
    }
}

rockier

Thu, 27 Jun 2013 19:00:31 +0000

I have got it to work. I add this command and it started working.

ConfigIntCapture1(IC_INT_ON | IC_INT_PRIOR_1);