Alexandru Savin
Newbie level 2
- Joined
- Jun 28, 2013
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 20
Hello i am trying to capture the first bit of an uart message with the CCP in capture mode, the problem is that once in a wile the interupt fires without any signal on the line, exactly when the interrupt is enabled(happens one every minute or so), i found this using an oscilloscope on the DEV2_LED, the delay between each uart frame is 20 ms, and the length of the frame is 2-3ms, i switch the interrupt off each time i receive the falling edge of the first bit of the frame and i putt it on back ~12ms after that, or at least that is what i want to do.
the ccp interrupt are enabled in high priority isr and thy are checked in low priority
a picture with the osciloscope can be see**broken link removed** , blue line DEV1_LED, yellow line UART,
later edit: after a little bit of digging up the the isr doesn't execute exactly after the delay, it waits 5-7ms and after that the interrupt is triggered, what could cause this scenario?
the ccp interrupt are enabled in high priority isr and thy are checked in low priority
a picture with the osciloscope can be see**broken link removed** , blue line DEV1_LED, yellow line UART,
later edit: after a little bit of digging up the the isr doesn't execute exactly after the delay, it waits 5-7ms and after that the interrupt is triggered, what could cause this scenario?
Code:
void ActivateCcpInterrupt(u8 channel)
{
switch(channel)
{
case 5:
CCP5IF = FALSE;
CCP5IE = TRUE;
break;
case 4:
CCP4IF = FALSE;
CCP4IE = TRUE;
break;
case 3:
CCP3IF = FALSE;
CCP3IE = TRUE;
break;
}
}
//this part is inside a timer interrupt that fires every ms
// the problem appears here afer the interrupt is se to enable the isr for the interrupt is executed without any signal on the uart, both of the lines are observed on the oscilloscope
//enabling the ccp interrupt after a 12ms delay
if(ccp3IsDisabled)
{
if(ccp3Timer-- == 0)
{
ccp3Timer = 12;
ccp3IsDisabled = FALSE;
ActivateCcpInterrupt(3);
}
}
if(ccp4IsDisabled)
{
if(ccp4Timer-- == 0)
{
ccp4Timer = 12;
ccp4IsDisabled = FALSE;
ActivateCcpInterrupt(4);
}
}
if(ccp5IsDisabled)
{
if(ccp5Timer-- == 0)
{
ccp5Timer = 12;
ccp5IsDisabled = FALSE;
ActivateCcpInterrupt(5);
}
}
// this part is inside the low priority isr
if(CCP3IF && CCP3IE)
{ //!< A capture interrupt is set for CCP3
temp=CCPR3;
CCP3IF=FALSE; //!< Set capture interrupt flag false
CCP3IE=FALSE; //!< Disable Capture interrupt
DEV3_LED = !DEV3_LED;
ccp3IsDisabled = TRUE;
CCP_time_log(2,temp); //!< Logging tmr value, for ccp3
}
if(CCP4IF && CCP4IE)
{ //!< A capture interrupt is set for CCP4
temp=CCPR4;
CCP4IF=FALSE; //!< Set capture interrupt flag false
CCP4IE=FALSE; //!< Disable Capture interrupt
// DEV2_LED = !DEV2_LED;
ccp4IsDisabled = TRUE;
CCP_time_log(1,temp); //!< Logging tmr value, for ccp4
}
if(CCP5IF && CCP5IE)
{ //!< A capture interrupt is set for CCP5
temp=CCPR5;
// COMPENSATE_TMR3(temp);
CCP5IF=FALSE; //!< Set capture interrupt flag false
CCP5IE=FALSE; //!< Disable Capture interrupt
DEV1_LED = !DEV1_LED;
ccp5IsDisabled = TRUE;
CCP_time_log(2,temp); //!< Logging tmr value, for ccp5
}
Last edited: