STM32 multi-block CAN bus interconnection card dead problem

There is no problem when a single board is connected to the CAN bus, but when multiple boards are connected to the CAN at the same time, basically only one can be used, and the other boards will be stuck. At first, it was determined to be a bus connection problem. , I tried to connect one or two 120ohm resistors to the bus, but it didn’t work. I used jlink to enter the debugging mode through keil and found that the program was stuck in the position below startup_stm32f10x_md.s. According to the teacher, this should be the interrupt service program of stm32. The entry position of the can be guessed that the CAN bus interrupt was not handled properly. The teacher asked if the receiving interrupt was handled. I said that there was no interrupt service for the can receiving.

273 ABLE B B 274

275 ENDP ABLE, then the program can be changed to ENDP

ABLE, then the program can be changed to ENDP

ABLE NS.

/*CAN FIFO0 message pending interrupt enable */

CAN_ITConfig(CAN1,CAN_IT_FMP0,ENABLE); //Enable FIFO0 message registration interrupt

When multiple CAN bus development boards are interconnected, either write a service program for the CAN receiving interrupt, or do not enable the receiving interrupt, that is, do not enable the FIFO0 message registration interrupt, otherwise an interrupt service program similar to the following should be added.

/* USB interrupt and CAN receive interrupt service routine, USB and CAN common I/O, only used here CAN interrupt. */void USB_LP_CAN1_RX0_IRQHandler(void){ CanRxMsg RxMessage; RxMessage.StdId=0x00; RxMessage.ExtId=0x00; RxMessage.IDE=0; RxMessage.DLC=0; RxMessage.FMI=0; RxMessage.Data[0]=0x00; RxMessage.Data[1]=0x00; CAN_Receive(CAN1,CAN_FIFO0, &RxMessage); //Receive the data in FIFO0 if((RxMessage.StdId==slaveID)&&(RxMessage.Data[0]==0x55)) {FABIAO =0xff;}    }

        总结:

        个人觉得自己有点偏执,开始一直认为单个通信正常,连在一起The abnormality is a problem of the external hardware configuration of the bus. I did not expect it to be a program configuration problem, but in the end it was roughly raised that it might be a can bus configuration problem, but because the stm32 can bus was not studied carefully, no problem was speculated.

Second, I didn’t make good use of jlink. I just used it as a downloader, but I still didn’t think about it. Do not enter the debug mode for analysis.

Leave a Comment

Your email address will not be published.