CAN CUMMUNICATION OSERROR:16

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
adrianhergi
Posts: 1
Joined: Thu Jan 11, 2018 3:00 pm

CAN CUMMUNICATION OSERROR:16

Post by adrianhergi » Mon Jan 15, 2018 7:40 am

Hello, I am traying to cummunicate via CAN using an OpenMV Cam and an SN65HVD230 part. I am only taying to send message from it using the following example but I am getting an OSError:16.

It seems that the transmit mailboxes of the MCU are full and the message can not be sent.


[code]
import sensor, image, time, utime
import pyb
from pyb import CAN

@micropython.asm_thumb
def can_debug():
movwt(r0, stm.CAN2)


can = pyb.CAN(2) #The bus 2(PB12, PB13) is the only can bus on the Open MVCam
import stm


can.init(pyb.CAN.NORMAL, extframe=False, prescaler=18, sjw=1, bs1=8, bs2=3) #250kb/s
# APB1 = 54MHz, Prescaler 18 et 250kB/s --> 12 time quanta par bit (1 + 8 + 3 = 12)
can.setfilter(0, pyb.CAN.LIST16, 0, [0x700, 0x700, 0x701, 0x702], rtr = [0, 1, 0, 0])

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)

clock = time.clock()
tiempo= utime.ticks_ms() # get millisecond counter
aux=pyb.freq();
print(aux)
print(help(stm))

while(True):
clock.tick()
img = sensor.snapshot()
data= b'\x01\x50'
tiempo2=utime.ticks_ms()
if (tiempo + 1000)< (tiempo2):
print("REGISTRO:")
# print(can_debug())
tiempo= utime.ticks_ms() # get millisecond counter
can.send(data, id = 0x702, timeout=50000, rtr=False)
print("can : message sent") #
[/code]


When I try to run it I get activity on the CanTX and CanRX pins on the board. However at the output of the SN65HVD230 I am not getting the correct value voltages for a CAN bus. I was trying to acces the CAN registers of the MCU in order to try to debuf, but I dont understand well how it works.

Post Reply