树莓派3B+使用RS485 CAN HAT模块

1. 配置CAN接口
编辑启动配置文件:

sudo leafpad /boot/config.txt
在最下面增加:

dtparam=spi=on 
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25,spimaxfrequency=1000000 
然后重启:

sudo reboot
测试接口,执行:

dmesg | grep -i '\(can\|spi\)'
成功后显示如下信息:

can0 即为CAN接口。

使用can0前需要运行:

sudo ip link set can0 type can bitrate 500000 restart-ms 100
sudo ifconfig can0 up
可以增加开机时启动:

编辑/etc/network/interfaces文件:

sudo leafpad /etc/network/interfaces
在最后增加:

allow-hotplug can0
iface can0 can static
    bitrate 500000
    restart-ms 100
2. 配置RS485接口
打开树莓派设置:

sudo raspi-config
依次选择 Interfacing Options - Serial :

编辑启动配置文件/boot/config.txt,确认如下行:

Enable_uart=1
#dtoverlay=pi3-miniuart-bt 
重启:

sudo reboot
/dev/ttyS0 即为串口。


————————————————
版权声明:本文为CSDN博主「lixiaoxin1989」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lixiaoxin1989/article/details/91905860

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值