CAN模块编译不通过?
-
# CAN循环测试 # CANbps= Fpclk/((BRP+1)*((Tseg1+1)+(Tseg2+1)+1) # 所以这里CANbps=APB1总线频率54000000/9/(7+4+1))=500k bps # 总体配置方向: Tseg1>=Tseg2 Tseg2>=tq; Tseg2>=2TSJW from pyb import CAN import time #freq = pyb.freq() can2 = CAN(2, CAN.NORMAL) can2.init(CAN.NORMAL,False,9,sjw=1,bs1=7,bs2=4) #500k波特率 can2.setfilter(0, CAN.LIST16, 0, (0,0,0,0)) # set a filter to receive messages with id=123, 124, 125 and 126 can2.send('12345678', 123) # send a message with id 123 while(True): # print(can2.recv(0,timeout=50000)) # receive message on FIFO 0 can2.send('12345678',123) # send a message with id 123 time.sleep(1000)
-
用的2.5.1IDE,固件3.6.4
-
看代码:
https://book.openmv.cc/example/02-Board-Control/can.htmlH7,也就是OpenMV4 和OpenMV4 Plus用CAN.RANGE,OpenMV3以及OpenMV2用CAN.LIST16