1、一、设置对应的 Lin 配置本例以 F28035 芯片的 GPIO9 和 GPIO11 为实例1、配置 IO 功能GpioCtrlRegs.GPAPUD.bit.GPIO9 = 0; GpioCtrlRegs.GPAQSEL1.bit.GPIO9 = 3;GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 2;GpioCtrlRegs.GPAPUD.bit.GPIO11 = 0;GpioCtrlRegs.GPAQSEL1.bit.GPIO11 = 3; GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 2;2、对应 LIN 配置EALLOW;LinaRegs.S
2、CIGCR0.bit.RESET = 0; /Into reset(复位)LinaRegs.SCIGCR0.bit.RESET = 1; /Out of reset(关复位)LinaRegs.SCIGCR1.bit.SWnRST = 0; /Into software reset(LIN 准备好)/LIN 配置LinaRegs.SCIGCR1.bit.COMMMODE = 0; /Idle-Line ModeLinaRegs.SCIGCR1.bit.TIMINGMODE = 1; /Asynchronous Timing(异步)LinaRegs.SCIGCR1.bit.PARITYENA =
3、0; /No Parity Check(无校验)LinaRegs.SCIGCR1.bit.PARITY = 0; /Odd Parity(奇校验)LinaRegs.SCIGCR1.bit.STOP = 1; /TWO Stop Bit(2 个停止位)LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; /Enable SCI Clock(SCI 时钟)LinaRegs.SCIGCR1.bit.LINMODE = 0; /SCI Mode(SCI 模式)LinaRegs.SCIGCR1.bit.SLEEP = 0; /Ensure Out of SleepLinaRegs.S
4、CIGCR1.bit.MBUFMODE = 0; /Buffered Mode(缓存模式)/LinaRegs.SCIGCR1.bit.LOOPBACK = 1; /Internal Loopback/LinaRegs.SCIGCR1.bit.CONT = 1; /Continue on SuspendLinaRegs.SCIGCR1.bit.RXENA = 1; /Enable RX(使能接收)LinaRegs.SCIGCR1.bit.TXENA = 1; /Enable TX(使能发送)/Ensure IODFT is disabled/LinaRegs.IODFTCTRL.bit.IODF
5、TENA = 0x0;/设置数据格式LinaRegs.SCIFORMAT.bit.CHAR = 7; /Eight bitsLinaRegs.SCIFORMAT.bit.LENGTH = 0; /ONE bytes/设置波特率LinaRegs.BRSR.bit.SCI_LIN_PSL = 96; /19.2 kbps for SYSCLKOUT = 60 MHzLinaRegs.BRSR.bit.M = 11;/中断使能LinaRegs.SCISETINT.bit.SETRXINT = 1; /Enable RX interruptLinaRegs.SCISETINT.bit.SETTXINT
6、 = 1;/设置中断线LinaRegs.SCISETINTLVL.bit.SETRXINTOVO =0;/接收在 LEVEL0LinaRegs.SCISETINTLVL.bit.SETTXINTLVL =1;/发送在 LEVEL1LinaRegs.SCIGCR1.bit.SWnRST = 1; /bring out of software reset/Disable write to protected registersEDIS;3、使能 LIN-SIC 时钟DSP2803x_SysCtrl.c 文件中的函数 InitPeripheralClocks()添加:SysCtrlRegs.PCLK
7、CR0.bit.LINAENCLK = 1; 使能 LIN 时钟二、开启对应的中断程序可以在 DSP28035 芯片资料 tms320f28035.pdf 的 vector table mapping 中查找到对应的中断号。故在 DSP2803x_PieVect.c 源文件程序中对于的 const struct PIE_VECT_TABLE PieVectTableInit 中的 Group 9 PIE Vectors 中添加 LIN0INTA_ISR、LIN1INTA_ISR。三、源代码/接收中断程序(中断线 0)interrupt void LIN0INTA_ISR(void) / LIN
8、Uint16 LinL0IntVect,temp;LinL0IntVect =LinaRegs.SCIINTVECT0.all;if(LinL0IntVect =11) /值为 11 时代表有数据接收到 /接收到数据if(InputPointer_testOutputPointer)if(OutputPointer=0)OutputPointer+;LinaRegs.SCITD =OutputBufferOutputPointer;OutputPointer+;EALLOW;LinaRegs.SCICLEARINT.bit.CLRTXINT =1;/关中断EDIS;EALLOW;LinaRegs.SCISETINT.bit.SETTXINT = 1; /开中断EDIS;while(LinaRegs.SCIFLR.bit.TXEMPTY = 0);while(LinaRegs.SCIFLR.bit.TXRDY = 0);elseOutputPointer =0;EALLOW;LinaRegs.SCICLEARINT.bit.CLRTXINT =1;/关中断EDIS;PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;