2015-04-23 08:36 AM
Hi,
I am writing a LINFLEX_0 driver for SPC560B60L3. DMA is not used as of now. All interrupts are disabled.
Linflex_0 can be configured in 2 sets of port pins
set 1: LIN0TX in PB[0] and LIN0RX in PB[1]. Alternate function in PB[0] is 3.
set 2: LIN0TX in PB[2] and LIN0RX in PB[3]. Alternate function in PB[0] is 1.If i use set2 i could see the LIN signals in the lin bus. However if i use set1 i do not see any lin signal. I checked the microcontroller pins using oscilloscope and did not see any signal.
I am writing the functions used as mentioned below.
int main (void)
{__DI(); // Disable All interrupts
Disable_Watchdog(); MCU_Mode_Init(); MCU_PLL_Init();/* RUN0 Module Config*/
ME.ME_RUN_MC[0].B.FXOSCON=1; ME.ME_RUN_MC[0].B.FMPLLON=1; ME.ME_RUN_MC[0].B.SYSCLK=4; ME.RUN_PC[0].B.RUN0 = 0x1; ME.PCTL[48].R = 0x00; ME.PCTL[49].R = 0x00; ME.PCTL[68].R = 0x00; /* DRUN-> RUN0 Transition*/ MCU_SetRunMode(4); #if 0 /* Non Working PORT COnfiguration */ SIU.PCR[16].B.PA = 0x3; SIU.PCR[17].B.IBE = 0x1; SIU.PSMI[62].B.PADSEL = 0x1; #else/* Working PORT COnfiguration */
SIU.PCR[18].B.PA = 0x1; SIU.PCR[19].B.IBE = 0x1; SIU.PSMI[62].B.PADSEL = 0x0; #endif LIN_InitChannel ( ); LIN_SendHeader( );/* Enable global interrupt */
__EI(); while(1); }void LIN_InitChannel( void )
{ LINCR1.B.INIT=1; /* Put the Device into Initialization mode*/ LINCR1.B.SLEEP = 0; /* sleep mode cleared*/ LINCR1.B.MBL =10; /* 20 bit synch */ LINCR1.B.MME=1; /* enable master mode*/ LINCR1.B.SFTM = 0; /* disabled self test mode*/ LINCR1.B.LBKM = 0; /* Enabled loop back mode */LINFLEX_Ptr->LINFBRR.B.DIV_F=0x5; /* Write fractional part first*/
LINFLEX_Ptr->LINIBRR.B.DIV_M=0xD0; LINFLEX_Ptr->LINCR1.B.INIT=0; }void LIN_SendHeader(void)
{LINFLEX_Ptr->BDRL.B.DATA0=0xF0;
LINFLEX_Ptr->BDRL.B.DATA1=0xF0; LINFLEX_Ptr->BDRL.B.DATA2=0xF0; LINFLEX_Ptr->BDRL.B.DATA3=0xF0; LINFLEX_Ptr->BDRM.B.DATA4=0xF0; LINFLEX_Ptr->BDRM.B.DATA5=0xF0; LINFLEX_Ptr->BDRM.B.DATA6=0xF0; LINFLEX_Ptr->BDRM.B.DATA7=0xF0;LINFLEX_Ptr->BIDR.B.ID=9; /* ID without Parity*/
LINFLEX_Ptr->BIDR.B.CCS=1; /* Checksum 0- enhanced, 1- classic*/ LINFLEX_Ptr->BIDR.B.DFL=7; /* Number of data bytes in the response part of the frame*/ LINFLEX_Ptr->BIDR.B.DIR=1;LINFLEX_Ptr->LINCR2.B.HTRQ = 1; /* Request header transmission */
/* If i check the LINS bit for 7, which should be the ideal case, it hangs up.
So i an checking for 6. Atleast i could see something in the bus */while(LINFLEX_Ptr->LINSR.B.LINS!=0x6);
}
I just tried to give a simple version of the driver here. Main point is it is working in 1 set of port and not working in the other.
Compiler used is : Greenhills 6.1.6Any help and hints would be highly appreciated.
Regards,
Saswat2015-04-24 01:52 AM
2015-04-27 03:44 AM
Hi, Thank you for the response. I use a motherboard from ST. I have found the root cause. I could see the Lin signals in the micro pin when they are terminated in a LIN transceiver. In case of the motherboard, the LIN transceiver is connected to PCR 18 and 19. So I could see the signals.
I hardwired PCR 16 and 17 to the LIN transceiver an I could see the signals there as well :). - Saswat2015-04-28 12:35 AM
Good news ;)
have a nice day ;) Erwan