luna-cycle / vesc_bms_fw

The VESC BMS Firmware
GNU General Public License v3.0
0 stars 0 forks source link

CANbus bitrates wrong #2

Closed nitrousnrg closed 2 years ago

nitrousnrg commented 2 years ago

To connect to a VESC controller at 500kbps, we need to configure the BMS at 1Mbps.

This probably started when we halved the peripheral clock frequency from 80MHz to 40MHz, so we gotta make the CANbus configuration consideral the PCLK frequency.

diegosarli commented 2 years ago

The baud rate is calculated using 80Mhz

https://github.com/luna-cycle/vesc_bms_fw/blob/6af13f26a5b80cb0026c5afb4cc41fe033e8d19c/comm_can.c#L912

this funcition is called here https://github.com/luna-cycle/vesc_bms_fw/blob/6af13f26a5b80cb0026c5afb4cc41fe033e8d19c/comm_can.c#L118

we can re configure can baud rate here:

https://github.com/luna-cycle/vesc_bms_fw/blob/6af13f26a5b80cb0026c5afb4cc41fe033e8d19c/hwconf/hw_luna_bms.c#L29

also baud rate parameter mus be saved in the backup memory

nitrousnrg commented 2 years ago

Yes, just hardcode it from hw_luna_init()and check if it works.

If it works lets close the issue. The tab in vesc tool that allows changing the baudrate is an XML stored inside our own firmware, we can modify it. If we decide 250kbps is the way to go we can leave it hardcoded.

Btw bafang uses 250kbps so we probably want to stay there.

diegosarli commented 2 years ago

fixed in fe670fd