Skip to content

STM32G0C1RE : Device never went into BusOff State #100

Description

@UmairAsghar-max

Problem

Recently, I have been working on integrating CAN bus LED indication patterns in accordance with CiA 303-3; https://wiki.sirius-es.it/it/procedure/canopen-led on STM32G0C1RE

  • RUN LED (Green): Operating as expected. The LED correctly reflects the defined patterns across different NMT states.
  • ERROR LED (Red): Consistently indicates “Sync Error: Triple Flash”, regardless of whether the device is connected to the CAN bus or not.

Observations

My device is acting as a heartbeat producer for now [OD >> max_DS301_profile.txt] and I believe that if I disconnect the device from the CAN bus for a certain period, the CAN controller will make the FDCAN protocol status register (FDCAN_PSR) bit 7 high, and the ERROR LED will be permanently ON.

CanOpenSTM32\CANopenNode_STM32\CO_driver_STM32.c : 414 onward

    err = ((FDCAN_HandleTypeDef*)((CANopenNodeSTM32*)CANmodule->CANptr)->CANHandle)->Instance->PSR
          & (FDCAN_PSR_BO | FDCAN_PSR_EW | FDCAN_PSR_EP);

    if (CANmodule->errOld != err) {

        uint16_t status = CANmodule->CANerrorStatus;

        CANmodule->errOld = err;

        if (err & FDCAN_PSR_BO) {
            status |= CO_CAN_ERRTX_BUS_OFF;
            // In this driver we expect that the controller is automatically handling the protocol exceptions.

        } else {
            /* recalculate CANerrorStatus, first clear some flags */
            status &= 0xFFFF
                      ^ (CO_CAN_ERRTX_BUS_OFF | CO_CAN_ERRRX_WARNING | CO_CAN_ERRRX_PASSIVE | CO_CAN_ERRTX_WARNING
                         | CO_CAN_ERRTX_PASSIVE);

            if (err & FDCAN_PSR_EW) {
                status |= CO_CAN_ERRRX_WARNING | CO_CAN_ERRTX_WARNING;
            }

            if (err & FDCAN_PSR_EP) {
                status |= CO_CAN_ERRRX_PASSIVE | CO_CAN_ERRTX_PASSIVE;
            }
        }

        CANmodule->CANerrorStatus = status;

But unfortunately, this is not the case. Bus never went into BusOff state;

  • err = 0x00000000 - When device is connected to CAN Bus and Turned On
  • err = 0x00000060 - When device is disconnected to CAN Bus
  • err = 0x00000040 - When device is connected to CAN Bus after Disconnecting

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions