Hi,
I have the following code:
In the setup/init function:
//Create Apply Timeout Timer
app_applyData.xTimer_Handle_ApplyTimeout = xTimerCreate("xSoftTmr_ApplyTimeout",
xPrinterData.uiApplyErrorTimeout,
pdTRUE,
( void * ) 0,
CBK_SoftTmr_ApplyTimeout);
In the function where I start the timer:
//set timeout time and start timer
xTimerStop(app_applyData.xTimer_Handle_ApplyTimeout, 0);
xTimerChangePeriod(app_applyData.xTimer_Handle_ApplyTimeout, xPrinterData.uiApplyErrorTimeout, 0); //reset time period to 100ms because there is no point in sampling faster
xTimerStart(app_applyData.xTimer_Handle_ApplyTimeout, 0);
Then is a ISR callback the following code (this is the entire callback):
void CBK_ChangeNotif_ApplicationGap(GPIO_PIN pin, uintptr_t context)
{
//Check which edge this INT was generated by
if (APPLIC_GAP_Get() == 0)
{
//INT was generated by falling edge (gap to label transition)
_nop();
//An edge was sensed so stop the timer to prevent timeout
xTimerStop(app_applyData.xTimer_Handle_ApplyTimeout, 0);
taskENTER_CRITICAL();
//set local flag that label edge has been detected
app_applyData.bLabelEdgeDetected = 1;
if (app_applyData.bApplyStopByStepCount == 0)
{
//clear the flag that the motor is running (because the motor is being stopped)
app_applyData.bApplyStepperIsRunning = 0;
//stop motor and timer
OCMP6_Disable();
TMR3_Stop ();
//redundant torque reduction. But placed here too for safety
Stepper_Apply_SetTorqueToThird();
}
taskEXIT_CRITICAL();
}
else
{
//INT was generated by rising edge (label to gap transition)
_nop();
}
_nop();
}
If I comment out the
xTimerStop(app_applyData.xTimer_Handle_ApplyTimeout, 0);
then the code runs as it should. Otherwise it doesn’t.
And what happens exactly is that none of the other interrupts that occur are serviced after then.
-
what could cause that?
-
have a number of software timers. Are there limits to the number of software timers I can create? Do I have to perhaps set some config variable somewhere?
UPDATE
Another thing that occurs if I leave that specific line in while debugging is that the debugger throws an exception and a software breakpoint with no functions shown in the call stack and the only information is a exception code of the MCU core itself. The only information on that code in the silicon manual is Bus Error Exception (instruction fetch). Nothing more. You can see entry/code 6 in table 2.10 on page 42 of the pdf here:
http://hades.mech.northwestern.edu/images/b/b1/PIC32RefManual-Dec2013.pdf
Thank you