完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
使用C8051F的单片机来实现CAN控制,可以进行数据的接收,发送不行
void CAN0_TransferMO (U8 obj_num){ // This function assumes that the message object is fully initialized // in CAN0_Init and so all it has to do is fill the data registers and // initiate transmission U8 SFRPAGE_save = SFRPAGE; SFRPAGE = CAN0_PAGE; // All CAN register are on page 0x0C // Initialize all 8 data bytes even though they might not be sent // The number to send was configured earlier by setting Message Control CAN0IF1DA1H = obj_num; // Initialize data registers based CAN0IF1DA1L = obj_num + 1; // on message object used CAN0IF1DA2H = obj_num + 2; CAN0IF1DA2L = obj_num + 3; CAN0IF1DB1H = obj_num + 4; CAN0IF1DB1L = obj_num + 5; CAN0IF1DB2H = obj_num + 6; CAN0IF1DB2L = obj_num + 7; CAN0IF1CM = 0x0087; // Set Direction to Write // Write TxRqst all 8 data bytes CAN0IF1CR = obj_num; // Start command request while (CAN0IF1CRH 0x80); // Poll on Busy bit SFRPAGE = SFRPAGE_save;} |
|
相关推荐
1个回答
|
|
8051本身没有CAN的收发器吧,必须要外接TTL转CAN的收发芯片才行,况且这种芯片的通信速度要求很高的,8051的速度远远不够。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-spi编程示例之spi编写程序
575 浏览 0 评论
《DNK210使用指南 -CanMV版 V1.0》第三十七章 image图像对比实验
554 浏览 0 评论
500 浏览 1 评论
482 浏览 0 评论
关于RT-Thread studio添加freemodbus控件失败的问题
817 浏览 1 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11641 浏览 31 评论
浏览过的版块 |
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-8 14:31 , Processed in 0.622214 second(s), Total 73, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号