关于can的自接收问题 查阅文档时看到一句话:
当产生自接收请求时,如果验收滤波器被设置成相应的标识符,则报文被发送,同时被接收,一个接收和发送中断将指示出正确的自接收。
不是很理解这句话
后面再LPC17XX的自接收例程中,发现代码中开启了两个中断:
//Enable Interrupt
CAN_IRQCmd(LPC_CAN1, CANINT_RIE, ENABLE);
CAN_IRQCmd(LPC_CAN1, CANINT_TIE1, ENABLE);
不明白为什么要开发送中断,中断服务函数里也没有和发送中断有关的内容:
void CAN_IRQHandler()
{
uint8_t IntStatus;
// uint32_t data1;
/* Get CAN status */
IntStatus = CAN_GetCTRLStatus(LPC_CAN1, CANCTRL_STS);
//check receive buffer status
if((IntStatus>>0)&0x01)
{
CAN_ReceiveMsg(LPC_CAN1,&RXMsg);
_DBG_("Received buffer:");
PrintMessage(&RXMsg);
//Validate received and transmited message
if(Check_Message(&TXMsg, &RXMsg))
_DBG_("Self test is SUCCESSFUL!!!");
else
_DBG_("Self test is FAIL!!!");
FIO_ByteSetValue(1, 3, 1<<4);
delay();
FIO_ByteClearValue(1, 3, 1<<4);
delay();
}
}
还有就是,不知道为什么不能给can发送函数加个while循环让它不停地发送数据:
int c_entry(void) { /* Main Program */
/* Initialize debug via UART0
* – 115200bps
* – 8 data bit
* – No parity
* – 1 stop bit
* – No flow control
*/
debug_frmwrk_init();
print_menu();
//FIO_ByteSetDir(1, 3, 1<<4, 1);
/* Initialize CAN1 peripheral
* Note: Self-test mode doesn't require pin selection
*/
CAN_Init(LPC_CAN1, 125000);
//Enable self-test mode
CAN_ModeConfig(LPC_CAN1, CAN_SELFTEST_MODE, ENABLE);
//Enable Interrupt
CAN_IRQCmd(LPC_CAN1, CANINT_RIE, ENABLE);
CAN_IRQCmd(LPC_CAN1, CANINT_TIE1, ENABLE);
//Enable CAN Interrupt
NVIC_EnableIRQ(CAN_IRQn);
CAN_SetAFMode(LPC_CANAF,CAN_AccBP);
CAN_InitMessage();
_DBG_("Transmitted buffer:");
PrintMessage(&TXMsg);
/** To test Bypass Mode: we send infinite messages to CAN2 and check
* receive process via COM1
*/
CAN_SendMsg(LPC_CAN1, &TXMsg);
LPC_CAN1->CMR |=(1<<4); //Self Reception Request
while (1);
}
此帖出自
小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
谢谢你 我是想知道这里为什么要开两个中断呢
http://bbs.eeworld.com.cn/thread-526723-1-1.html
帮我看看这个 我写详细了 谢谢你
一周热门 更多>