stm8S208仿真时CAN发送报文错误状态寄存器提示格式错误,用的IAR
CAN_MCR_TTOM = 0; //禁止时间触发通信
CAN_MCR_ABOM = 1; //自动退出离线
CAN_MCR_AWUM = 1; //自动唤醒
CAN_MCR_NART = 1; //禁止报文自动重传
CAN_MCR_RFLM = 0; //接收不锁定FIFO
CAN_MCR_TXFP = 0; //发送优先级由报文ID决定
CAN_MCR_SLEEP = 0; //CAN不休眠
CAN_MCR_INRQ = 1; //CAN进入初始化模式
CAN_IER_FMPIE = 1; //FIFO有新字节允许中断
SWITCH_CAN_PAGE(CONFIG); //选择设置/诊断页
CAN_P4 = 0x0a; //设置波特率
CAN_P5 = 0x10; //设置波特率
CAN_P8 = 0xff; //过滤器0123工作在ID列表模式
CAN_P9 = 0x0f; //过滤器45工作在ID列表模式
CAN_PA = 0x66; //禁用过滤器01,并设置位宽32
CAN_PB = 0x66; //禁用过滤器23,并设置位宽32
CAN_PC = 0x66; //禁用过滤器45,并设置位宽32
// CAN_DGR_SILM = 1; //进入静默模式
// CAN_DGR_LBKM = 1; //允许环回模式
CAN_MCR_INRQ = 0; //CAN进入正常模式
if(CAN_TPR_TME0)
{
SWITCH_CAN_PAGE(TX_MAIL_BOX0); //切换到邮箱0页
CAN_P1 = 0x08;
CAN_P2 = 0x08;
CAN_P3 = 0x00;
CAN_P6 = 0x55;
CAN_P7 = 0x55;
CAN_P8 = 0x55;
CAN_P9 = 0x55;
CAN_PA = 0x55;
CAN_PB = 0x55;
CAN_PC = 0x55;
CAN_PD = 0x55;
CAN_P0 = 0x01; //申请发送请求
}
while(CAN_TSR_TXQOK0 != 1 && CAN_TSR_RQCP0 != 1); //等待发送完成
CAN_TSR_RQCP0 = 1; //清0
此帖出自
小平头技术问答
一周热门 更多>