Skip to content

STM32 CAN bus #5059

@pilotak

Description

@pilotak

I tried CAN bus sucessfully on LPC1768, now i moved to NUCLEO_F142ZG and NUCLEO_F103RB but i can't get it to work. Same code works on LPC but doesn't on STM32. Is CAN not supported on STM? I looked at transmit pin through scope and there is nothing = pin HIGH.

#include "mbed.h"
CAN can1(PB_8, PB_9);
DigitalOut led1(LED1);
char counter = 0;

int main() {
    printf("start\n");
    
    can1.frequency(250000);
    can1.reset();
    can1.mode(CAN::Normal);

    while(1) {
        if(can1.write(CANMessage(1337, &counter, 1))) {
            printf("sent\n");
        } 
        else {
            printf("error\n");
        }
        counter++;
        led1 = !led1;
        
        wait_ms(100);
    }
}

It prints 3x "sent" (but not visible on scope) and then error forever

Description

  • Type: Question
  • Related issue: #abc
  • Priority: Blocker | Major | Minor

Target
STM32

Toolchain:
GCC_ARM & online

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions