I need to check 3 input signals connected to fan control pins.
The code below works only if instead of 3 signals I configure 2. At the third signal added the callback function is called but the returned value is always 0
void SCT_Initial_Detection_Callback1(void){
CaptureVal1 = SCTIMER_1_PERIPHERAL->SCTCAP[CaptureReg1];
}
Can anyone tell me what I'm doing wrong?
Thanks
Code:
/* Schedule an event to look for a rising edge on input 1 */
if (SCTIMER_CreateAndScheduleEvent(SCTIMER_1_PERIPHERAL,
kSCTIMER_InputRiseEvent,
0,
kSCTIMER_Input_1,
kSCTIMER_Counter_L,
&initialRisingEdgeInput1) == kStatus_Fail)
{
PRINTF(" SCTIMER_CreateAndScheduleEvent1 ERROR \r\n ");
return(-1);
}
if (SCTIMER_SetupCaptureAction(SCTIMER_1_PERIPHERAL,
kSCTIMER_Counter_L,
&CaptureReg1,
initialRisingEdgeInput1) == kStatus_Fail)
{
PRINTF(" SCTIMER_SetupCaptureAction1 ERROR \r\n ");
return(-1);
}
/* Schedule an event to look for a rising edge on input 2 */
if (SCTIMER_CreateAndScheduleEvent(SCTIMER_1_PERIPHERAL,
kSCTIMER_InputRiseEvent,
0,
kSCTIMER_Input_2,
kSCTIMER_Counter_L,
&initialRisingEdgeInput2) == kStatus_Fail)
{
PRINTF(" SCTIMER_CreateAndScheduleEvent2 ERROR \r\n ");
return(-1);
}
if (SCTIMER_SetupCaptureAction(SCTIMER_1_PERIPHERAL,
kSCTIMER_Counter_L,
&CaptureReg2,
initialRisingEdgeInput2) == kStatus_Fail)
{
PRINTF(" SCTIMER_SetupCaptureAction2 ERROR \r\n ");
return(-1);
}
/* Schedule an event to look for a rising edge on input 3 */
if (SCTIMER_CreateAndScheduleEvent(SCTIMER_1_PERIPHERAL,
kSCTIMER_InputLowEvent,
0,
kSCTIMER_Input_3,
kSCTIMER_Counter_L,
&initialRisingEdgeInput3) == kStatus_Fail)
{
PRINTF(" SCTIMER_CreateAndScheduleEvent3 ERROR \r\n ");
return(-1);
}
if (SCTIMER_SetupCaptureAction(SCTIMER_1_PERIPHERAL,
kSCTIMER_Counter_L,
&CaptureReg3,
initialRisingEdgeInput3) == kStatus_Fail)
{
PRINTF(" SCTIMER_SetupCaptureAction3 ERROR \r\n ");
return(-1);
}
/* Set the callback funcitons */
SCTIMER_SetCallback(SCTIMER_1_PERIPHERAL, SCT_Initial_Detection_Callback1, initialRisingEdgeInput1);
SCTIMER_SetCallback(SCTIMER_1_PERIPHERAL, SCT_Initial_Detection_Callback2, initialRisingEdgeInput2);
SCTIMER_SetCallback(SCTIMER_1_PERIPHERAL, SCT_Initial_Detection_Callback3, initialRisingEdgeInput3);
/* Enable interrupts for both events */
SCTIMER_EnableInterrupts(SCTIMER_1_PERIPHERAL, 1 << initialRisingEdgeInput1);
SCTIMER_EnableInterrupts(SCTIMER_1_PERIPHERAL, 1 << initialRisingEdgeInput2);
SCTIMER_EnableInterrupts(SCTIMER_1_PERIPHERAL, 1 << initialRisingEdgeInput3);
NVIC_EnableIRQ(SCTIMER_1_IRQN);
SCTIMER_StartTimer(SCTIMER_1_PERIPHERAL, kSCTIMER_Counter_L);
Solved! Go to Solution.
Hello ,
It failed when I download your project with private message:
How about change
kSCTIMER_InputLowEvent, to kSCTIMER_InputRiseEvent,
in input 3 setting.
And first just use the only one input to test.
Regards,
Alice
Hello,
"the callback function is called but the returned value is always 0"
->> What about your callback function, what value it returned?
You can attached your whole project, I will help to check on my side.
Regard,
Alice
Hello Alice,
I sent you the demo code in a private message.
Regard,
Veronica
Hello ,
It failed when I download your project with private message:
How about change
kSCTIMER_InputLowEvent, to kSCTIMER_InputRiseEvent,
in input 3 setting.
And first just use the only one input to test.
Regards,
Alice