Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

c++ - CAN BUS STM32 Nucleo F429ZI CAN Write Fail

It is Veysel My board is STM32 Nucleo F429ZI and I use Mbed-os 6.6.0. I can read from my car CANBus data but I am not able to write on the bus. I tried it with two STM32 (same boards) and my trancivers are SN65HVD230 So I know that I can read on the CANBus , but I cannot write.

I have tried , https://os.mbed.com/users/WiredHome/notebook/can---getting-started/ with one STM32 and I have tried

#include "mbed.h"

//Ticker ticker;
DigitalOut led1(LED1);
DigitalOut led2(LED2);
//CAN can1(PD_0, PD_1);
CAN can2(PB_8, PB_9);
DigitalOut led3(LED3);
 
 
char counter = 0;
 
void messageReceivedISR() {
 CANMessage msg;
 if(can2.read(msg)) {
        printf("Message received: %d, from %d
", msg.data[0], msg.id);
        if(msg.id == 1100)
            led2 = !led2;
        if(msg.id == 1102)
            led3 = !led3;     
}
 
   
}
 
int main() {

   
can2.frequency(1000000);
can2.reset();
can2.attach(&messageReceivedISR, CAN::RxIrq);
while(1) {
    if(can2.write(CANMessage(1130, &counter, 1))) {
        printf("loop send()
");
        counter++;
        printf("Message sent: %d
", counter);
        led1 = !led1;
    }
    
   // wait_ms(500);
}
}

I switch writing address for both stm32 This is fulling mailbox three times and stop. None read.

I have tried directly connect with one jumper from Crx to Ctx but nothing changes.

I also tried it with STM32 to Teensy ( Teensy is controing my cars LED Screen it can also read ) , but failed.

Please Help ?

question from:https://stackoverflow.com/questions/65920457/can-bus-stm32-nucleo-f429zi-can-write-fail

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

for me it sounds like you forgot to drive the "RS"-pin of the CAN Transciever. This is a bit misleading in the datasheet, but it is not only "slope" control, but it also sets the Transciever to sleep. I'd recommend to use a 10k slope control resistor unlesss needed otherwise as shown here: Schematics


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...