Skip to main content
Explorer
April 11, 2024
Solved

CAN and USB on STM32767ZiT6

  • April 11, 2024
  • 3 replies
  • 4594 views

Hello,

I have a custom board based on STM32767ZIT6 and it has the three CAN peripherals and the USB designed. The goal is to translate the CAN message to USB directly without the need for a bridge but I am facing issues activating the USB and the three CAN peripherals in the software. I am using basic CDC and when I connect the CAN port to a CAN network using the CANDoISO device, the USB disappear from the device manager and the GUI application.
Is it possible to use all three CAN peripherals with USB enabled or  have I messed up the configurations such as interrupt priorities and timing or will an RTOS help here?

    This topic has been closed for replies.
    Best answer by mƎALLEm

    These are bad config for CAN bitrate:

    hcan1.Init.TimeSeg1 = CAN_BS1_1TQ;
    hcan1.Init.TimeSeg2 = CAN_BS2_1TQ;

    Need to increase BS1 and BS2 and decrease the prescaler as much as possible in such way BS1 =~(75% to 85%) of (BS1+BS2).

    Example with bitrate @625kb/s with a sampling point at 80%: prescaler =3, BS1=12, BS2 = 3. 

    SofLit_0-1712918104521.png

     

     

    3 replies

    Technical Moderator
    April 11, 2024

    Hello, 

    What do you mean by « connect the CAN port to a CAN network using a CANDoISO device?

    please provide more details provide a schema.

    Which CAN instance do you connect makes the behavior occur?

    Check if you have some IO conflicts?

    WIFAuthor
    Explorer
    April 11, 2024

    I was seeing the behavior with CAN1 instance. Today I don't see the behavior but still have not USB and CAN communication.

    I am trying to get data from the CAN port and store it in a Tx FIFO that USB service reads from periodically to transfer data to the computer. Also I want to store the data received from USB in the Rx FIFO and the data CAN peripherals can read from periodically.

    WIF_1-1712835996221.png

     

    Technical Moderator
    April 11, 2024

    when I connect the CAN port to a CAN network using the CANDoISO device, the USB disappear from the device manager and the GUI application.

    Are you telling that this is a runtime issue? i.e. The USB is detected by your Host but when you connect to the CAN network the USB device is no more detected. By the way which CAN instance is causing that behavior?

    WIFAuthor
    Explorer
    April 11, 2024

    Yes, the USB is detected by the host and I can do basic echo app. I was using CAN1 instance. Maybe it was my wiring and cables yesterday because today I don't observe the issue.

    I wish to ask how I can simulate the triggering of CAN_IT_RX_FIFO0_MSG_PENDING interrupt that will call the HAL_CAN_RxFifo0MsgPendingCallback ISR. I have added the code to save the data gotten to from the CAN Rx FiFo to the USB Tx fifo but can't really test it without proper CAN device to connect to the peripheral

    Technical Moderator
    April 11, 2024

    I wish to ask how I can simulate the triggering of CAN_IT_RX_FIFO0_MSG_PENDING interrupt that will call the HAL_CAN_RxFifo0MsgPendingCallback ISR. I have added the code to save the data gotten to from the CAN Rx FiFo to the USB Tx fifo but can't really test it without proper CAN device to connect to the peripheral


    Here, I can suggest to use CAN in combined mode so the CAN cell is totally disconnected from outside the chip: no HW dependency.

    SofLit_0-1712839504594.png

     

    Technical Moderator
    April 12, 2024

    Good :smiling_face_with_smiling_eyes:!