~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ incap2isrwrapper.S
include <p32xxxx.h>
include <sys/asm.h>
include “ISR_Support.h”
.set nomips16
.set noreorder
.extern vInputCapture2InterruptHandler
.extern xISRStackTop
.global vInputCapture2InterruptWrapper
.set noreorder
.set noat
.ent vInputCapture2InterruptWrapper
vInputCapture2InterruptWrapper:
portSAVE_CONTEXT
jal vInputCapture2InterruptHandler
nop
portRESTORE_CONTEXT
.end vInputCapture2InterruptWrapper
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ isr.c void __ISR(INPUTCAPTURE2VECTOR, ipl6) vInputCapture2InterruptWrapper(void); void vInputCapture2InterruptHandler(void) { static portBASETYPE xHigherPriorityTaskWoken; uint16t input_capture = 0; /* Varable where the input capture value is read */ xHigherPriorityTaskWoken = pdFALSE; // Clear the interrupt flag INTClearFlag(INTSOURCEINPUTCAP(INTIC2)); /*————————— Add Application Code Here ——————————- */ if (mIC2CaptureReady()) { /* Read captures while there still data in the capture buffer */ do { input_capture = mIC2ReadCapture(); }while(mIC2CaptureReady()); } xQueueSendFromISR(InputCapDrvEventQueue, &input_capture, xHigherPriorityTaskWoken); /* ———————————————————————————— */ /* If DMA interrupt necessitates a context switch, then switch now. */ portEND_SWITCHING_ISR(xHigherPriorityTaskWoken); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ input_compare.c static void InputCapDriverSetup(void) { /* Set INT controller priority */ INTSetVectorPriority(INTVECTORINPUTCAP(INTINPUTCAPTURE2VECTOR), (configKERNELINTERRUPTPRIORITY + 2)); INTSetVectorSubPriority(INTVECTORINPUTCAP(INTINPUTCAPTURE2VECTOR), (configMAXSYSCALLINTERRUPTPRIORITY)); OpenTimer2(T2ON | T2SOURCEINT | T2PS1256 | T2IDLECON, PERIOD); OpenCapture2(ICEVERYRISEEDGE | ICINT1CAPTURE | ICTIMER2SRC | ICCAP16BIT | ICIDLECON | ICON); INTEnable(INTIC2, INTENABLED); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think everything is alright but if I put a breakpoint in the handler the execution doesn’t stop. If I hit “pause” in the debug session then the IFS0 register show that the IC2IF is set and also the IC2CON shows that there is a capture present (ICBNE = 1). Also I’ve verified that IC2IE at IEC0 is set so I don’t know what happens. Has anybody used the PIC32 Input Capture module with FreeRTOS and have a working example? By the way, I have a 25Hz 50% duty cycle pwm signal at the IC2 input pin so I think that’s not the problem. Regards