TI中文支持网
TI专业的中文技术问题搜集分享网站

28035LIN配置为485问题

void lin_init()
{
EALLOW;
LinaRegs.SCIGCR0.bit.RESET = 0; //Into reset
LinaRegs.SCIGCR0.bit.RESET = 1; //Out of reset
LinaRegs.SCIGCR1.bit.SWnRST = 0; //Into software reset

//SCI Configurations
LinaRegs.SCIGCR1.bit.COMMMODE = 0; //Idle-Line Mode
LinaRegs.SCIGCR1.bit.TIMINGMODE = 1; //Asynchronous Timing
LinaRegs.SCIGCR1.bit.PARITYENA = 0; //No Parity Check
LinaRegs.SCIGCR1.bit.PARITY = 0; //Odd Paritys
LinaRegs.SCIGCR1.bit.STOP = 0; //One Stop Bit
LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; //Enable SCI Clock
LinaRegs.SCIGCR1.bit.LINMODE = 0; //SCI Mode
LinaRegs.SCIGCR1.bit.SLEEP = 0; //Ensure Out of Sleep
LinaRegs.SCIGCR1.bit.MBUFMODE = 1; //Buffered Mode 此程序中使用缓存模式
LinaRegs.SCIGCR1.bit.LOOPBACK = 0; //Internal Loopback
LinaRegs.SCIGCR1.bit.CONT = 1; //Continue on Suspend
LinaRegs.SCIGCR1.bit.RXENA = 1; //Enable RX
LinaRegs.SCIGCR1.bit.TXENA = 1; //Enable TX

//Ensure IODFT is disabled
LinaRegs.IODFTCTRL.bit.IODFTENA = 0x0;

//Set transmission length
LinaRegs.SCIFORMAT.bit.CHAR = 7; //Eight bits
LinaRegs.SCIFORMAT.bit.LENGTH = 0; //one bytes 此处注意

//Set baudrate
LinaRegs.BRSR.bit.SCI_LIN_PSL = 194; //9600kbps for SYSCLKOUT = 60 MHz
LinaRegs.BRSR.bit.M = 0; // 官方说的是这个值为 5,但实测 0 比 5 要稳定

//中断使能
LinaRegs.SCISETINT.bit.SETRXINT = 1; //Enable RX interrupt
LinaRegs.SCISETINT.bit.SETTXINT = 1;
//设置中断线
//LinaRegs.SCISETINTLVL.bit.SETRXINTOVO =0; //接收在LEVEL0
//LinaRegs.SCISETINTLVL.bit.SETTXINTLVL =1; //发送在LEVEL1
LinaRegs.SCICLEARINTLVL.all = 0xFFFFFFFF; // Set Int level of all interrupts to LVL 0
LinaRegs.SCIGCR1.bit.SWnRST = 1; //bring out of software reset
EDIS;

//EALLOW;
//PieVectTable.LIN0INTA = &Lina_Level0_ISR;
// PieVectTable.LIN1INTA = &Lina_Level1_ISR;

//IER |= M_INT9;
//SysCtrlRegs.PCLKCR0.bit.LINAENCLK = 1; //使能LIN时钟
//PieCtrlRegs.PIEIER9.bit.INTx3=1; // PIE Group 9, INT3
//PieCtrlRegs.PIEIER9.bit.INTx4=1; // PIE Group 9, INT4
//EINT;
}

will zhang6:

附件是自己写的485程序,但是一致通讯不上,求赐教!!!

void lin_init()
{
EALLOW;
LinaRegs.SCIGCR0.bit.RESET = 0; //Into reset
LinaRegs.SCIGCR0.bit.RESET = 1; //Out of reset
LinaRegs.SCIGCR1.bit.SWnRST = 0; //Into software reset

//SCI Configurations
LinaRegs.SCIGCR1.bit.COMMMODE = 0; //Idle-Line Mode
LinaRegs.SCIGCR1.bit.TIMINGMODE = 1; //Asynchronous Timing
LinaRegs.SCIGCR1.bit.PARITYENA = 0; //No Parity Check
LinaRegs.SCIGCR1.bit.PARITY = 0; //Odd Paritys
LinaRegs.SCIGCR1.bit.STOP = 0; //One Stop Bit
LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; //Enable SCI Clock
LinaRegs.SCIGCR1.bit.LINMODE = 0; //SCI Mode
LinaRegs.SCIGCR1.bit.SLEEP = 0; //Ensure Out of Sleep
LinaRegs.SCIGCR1.bit.MBUFMODE = 1; //Buffered Mode 此程序中使用缓存模式
LinaRegs.SCIGCR1.bit.LOOPBACK = 0; //Internal Loopback
LinaRegs.SCIGCR1.bit.CONT = 1; //Continue on Suspend
LinaRegs.SCIGCR1.bit.RXENA = 1; //Enable RX
LinaRegs.SCIGCR1.bit.TXENA = 1; //Enable TX

//Ensure IODFT is disabled
LinaRegs.IODFTCTRL.bit.IODFTENA = 0x0;

//Set transmission length
LinaRegs.SCIFORMAT.bit.CHAR = 7; //Eight bits
LinaRegs.SCIFORMAT.bit.LENGTH = 0; //one bytes 此处注意

//Set baudrate
LinaRegs.BRSR.bit.SCI_LIN_PSL = 194; //9600kbps for SYSCLKOUT = 60 MHz
LinaRegs.BRSR.bit.M = 0; // 官方说的是这个值为 5,但实测 0 比 5 要稳定

//中断使能
LinaRegs.SCISETINT.bit.SETRXINT = 1; //Enable RX interrupt
LinaRegs.SCISETINT.bit.SETTXINT = 1;
//设置中断线
//LinaRegs.SCISETINTLVL.bit.SETRXINTOVO =0; //接收在LEVEL0
//LinaRegs.SCISETINTLVL.bit.SETTXINTLVL =1; //发送在LEVEL1
LinaRegs.SCICLEARINTLVL.all = 0xFFFFFFFF; // Set Int level of all interrupts to LVL 0
LinaRegs.SCIGCR1.bit.SWnRST = 1; //bring out of software reset
EDIS;

//EALLOW;
//PieVectTable.LIN0INTA = &Lina_Level0_ISR;
// PieVectTable.LIN1INTA = &Lina_Level1_ISR;

//IER |= M_INT9;
//SysCtrlRegs.PCLKCR0.bit.LINAENCLK = 1; //使能LIN时钟
//PieCtrlRegs.PIEIER9.bit.INTx3=1; // PIE Group 9, INT3
//PieCtrlRegs.PIEIER9.bit.INTx4=1; // PIE Group 9, INT4
//EINT;
}

HH Y:

回复 will zhang6:

我看到使能LIN时钟的语句被注释掉了,其他地方是否有打开这个时钟?

void lin_init()
{
EALLOW;
LinaRegs.SCIGCR0.bit.RESET = 0; //Into reset
LinaRegs.SCIGCR0.bit.RESET = 1; //Out of reset
LinaRegs.SCIGCR1.bit.SWnRST = 0; //Into software reset

//SCI Configurations
LinaRegs.SCIGCR1.bit.COMMMODE = 0; //Idle-Line Mode
LinaRegs.SCIGCR1.bit.TIMINGMODE = 1; //Asynchronous Timing
LinaRegs.SCIGCR1.bit.PARITYENA = 0; //No Parity Check
LinaRegs.SCIGCR1.bit.PARITY = 0; //Odd Paritys
LinaRegs.SCIGCR1.bit.STOP = 0; //One Stop Bit
LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; //Enable SCI Clock
LinaRegs.SCIGCR1.bit.LINMODE = 0; //SCI Mode
LinaRegs.SCIGCR1.bit.SLEEP = 0; //Ensure Out of Sleep
LinaRegs.SCIGCR1.bit.MBUFMODE = 1; //Buffered Mode 此程序中使用缓存模式
LinaRegs.SCIGCR1.bit.LOOPBACK = 0; //Internal Loopback
LinaRegs.SCIGCR1.bit.CONT = 1; //Continue on Suspend
LinaRegs.SCIGCR1.bit.RXENA = 1; //Enable RX
LinaRegs.SCIGCR1.bit.TXENA = 1; //Enable TX

//Ensure IODFT is disabled
LinaRegs.IODFTCTRL.bit.IODFTENA = 0x0;

//Set transmission length
LinaRegs.SCIFORMAT.bit.CHAR = 7; //Eight bits
LinaRegs.SCIFORMAT.bit.LENGTH = 0; //one bytes 此处注意

//Set baudrate
LinaRegs.BRSR.bit.SCI_LIN_PSL = 194; //9600kbps for SYSCLKOUT = 60 MHz
LinaRegs.BRSR.bit.M = 0; // 官方说的是这个值为 5,但实测 0 比 5 要稳定

//中断使能
LinaRegs.SCISETINT.bit.SETRXINT = 1; //Enable RX interrupt
LinaRegs.SCISETINT.bit.SETTXINT = 1;
//设置中断线
//LinaRegs.SCISETINTLVL.bit.SETRXINTOVO =0; //接收在LEVEL0
//LinaRegs.SCISETINTLVL.bit.SETTXINTLVL =1; //发送在LEVEL1
LinaRegs.SCICLEARINTLVL.all = 0xFFFFFFFF; // Set Int level of all interrupts to LVL 0
LinaRegs.SCIGCR1.bit.SWnRST = 1; //bring out of software reset
EDIS;

//EALLOW;
//PieVectTable.LIN0INTA = &Lina_Level0_ISR;
// PieVectTable.LIN1INTA = &Lina_Level1_ISR;

//IER |= M_INT9;
//SysCtrlRegs.PCLKCR0.bit.LINAENCLK = 1; //使能LIN时钟
//PieCtrlRegs.PIEIER9.bit.INTx3=1; // PIE Group 9, INT3
//PieCtrlRegs.PIEIER9.bit.INTx4=1; // PIE Group 9, INT4
//EINT;
}

mi chen:

请问这个问题你现在解决了吗?我现在也遇到类似的问题,用28034的LIN配置成SCI模式,和另一块28034的标准SCI模块通信,发送的数据在管脚上看不到,接受的收据也不能进入接收中断。请教了!

赞(0)
未经允许不得转载:TI中文支持网 » 28035LIN配置为485问题
分享到: 更多 (0)