This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Lin interrupt problem

Hello,

I'm working in lin mode with the LM4F232H5QC micro controller. I activate in the init part the sb,edge1,edge5 and rx interrupt like the data sheet request and activate the lin.

My problem is that the edge1 and edge5 i dont get correctly so sometimes he detect edge1 but not edge5 or he detect only sb and not the other. So i cant calculate correctly the frequency. 

I add my code. What seems to be the problem? 

void
uart2_IntHandler()
{
unsigned long ulStatus;
char newData,Tmp;
int i;

ulStatus = UARTIntStatus(UART2_BASE, true);

//Read Sync Break
if (ulStatus & UART_INT_LIN_SB)
{
Tmp=HWREG(UART2_BASE+UART_O_DR);
o_debug_printf(3,"\n\rSB\n\r");
}

if (ulStatus & UART_INT_LIN_EDGE1)
{
LinTimer1st=HWREG(UART2_BASE+UART_O_LTIM);
}

if (ulStatus & UART_INT_LIN_EDGE5)
{
LinTimer5th=HWREG(UART2_BASE+UART_O_LTIM);
LinFreq=((LinTimer5th-LinTimer1st)/2);
}

}
if (ulStatus & UART_INT_RX)
{
while(UARTCharsAvail(UART2_BASE))
{
newData = UARTCharGetNonBlocking(UART2_BASE);

LinBUARTbuffC[LinBUartBufferCIndex++] = newData;
}

}

UARTIntClear(UART2_BASE, ulStatus);
}


void
init_uart()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH2_UART2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

GPIOPinConfigure(GPIO_PD6_U2RX);
GPIOPinConfigure(GPIO_PD7_U2TX);

GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7);
UARTConfigSetExpClk(UART2_BASE, SysCtlClockGet(), 10000,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));

//LIN Mode Enable
HWREG(UART2_BASE+UART_O_CTL) |= (UART_CTL_LIN |UART_CTL_RXE |UART_CTL_UARTEN );

//Define Lin intterupts
UARTIntEnable(UART2_BASE, UART_INT_RX | UART_INT_LIN_SB
| UART_INT_LIN_EDGE1 | UART_INT_LIN_EDGE5);

UARTFlowControlSet(UART2_BASE,UART_FLOWCONTROL_NONE);
UARTFIFOLevelSet(UART2_BASE,UART_FIFO_TX4_8,UART_FIFO_RX1_8);
UARTEnable(UART2_BASE);

IntPrioritySet(INT_UART2,PRIO_LEVEL4);

IntMasterEnable(); //Enable Interrupt
IntEnable(INT_UART2);


}