在线时间0 小时
UID124591
注册时间2009-2-14
NXP金币0
该用户从未签到
新手上路

- 积分
- 4
- 最后登录
- 1970-1-1
|
我遇到的问题,CAN发送后,缓存区一直满 (CANTFLG = 0),调试过程中发现。发现寄存器CANCTL0在0 和16间跳动。就是CAN总线同步状态不稳定。CAN模块采用PE生成的代码。CW5.1编译。
CAN代码如下,请教,程序哪个方面配置错了??
初始化代码如下:
void CAN1_Init(void)
{
/* CANCTL1: CANE=1,CLKSRC=0,LOOPB=0,LISTEN=0,BORM=0,WUPM=0,SLPAK=0,INITAK=0 */
CANCTL1 = 0x80U; /* Set the control register */
/* CANCTL0: RXFRM=0,RXACT=0,CSWAI=0,SYNCH=0,TIME=0,WUPE=0,SLPRQ=0,INITRQ=1 */
CANCTL0 = 0x01U; /* Set the control register */
CANIDAC_IDAM = 0x01U; /* Set the acceptance mode */
CANIDAR0 = 0x00U; /* Set the acceptance code, register CANIDAR0 */
CANIDAR1 = 0x00U; /* Set the acceptance code, register CANIDAR1 */
CANIDAR2 = 0x00U; /* Set the acceptance code, register CANIDAR2 */
CANIDAR3 = 0x00U; /* Set the acceptance code, register CANIDAR3 */
CANIDAR4 = 0x00U; /* Set the acceptance code, register CANIDAR4 */
CANIDAR5 = 0x00U; /* Set the acceptance code, register CANIDAR5 */
CANIDAR6 = 0x00U; /* Set the acceptance code, register CANIDAR6 */
CANIDAR7 = 0x00U; /* Set the acceptance code, register CANIDAR7 */
CANIDMR0 = 0xFFU; /* Set the acceptance mask, register CANIDMR0 */
CANIDMR1 = 0xFFU; /* Set the acceptance mask, register CANIDMR1 */
CANIDMR2 = 0xFFU; /* Set the acceptance mask, register CANIDMR2 */
CANIDMR3 = 0xFFU; /* Set the acceptance mask, register CANIDMR3 */
CANIDMR4 = 0xFFU; /* Set the acceptance mask, register CANIDMR4 */
CANIDMR5 = 0xFFU; /* Set the acceptance mask, register CANIDMR5 */
CANIDMR6 = 0xFFU; /* Set the acceptance mask, register CANIDMR6 */
CANIDMR7 = 0xFFU; /* Set the acceptance mask, register CANIDMR7 */
/* CANBTR0: SJW1=1,SJW0=1,BRP5=0,BRP4=0,BRP3=0,BRP2=0,BRP1=0,BRP0=0 */
CANBTR0 = 0xC0U; /* Set the device timing register */
/* CANBTR1: SAMP=1,TSEG22=1,TSEG21=1,TSEG20=1,TSEG13=0,TSEG12=1,TSEG11=1,TSEG10=0 */
CANBTR1 = 0xF6U; /* Set the device timing register */
CANCTL1_CLKSRC = 0x01U; /* Select the clock source from bus clock */
CANCTL0_INITRQ = 0x00U; /* Start device */
while(CANCTL1_INITAK) {} /* Wait for enable */
}
|
|