سؤال

I am working with an LPC1768 ARM Cortex M3 microcontroller by NXP (datasheet, user manual). I would like to test the CAN bus peripheral in the self test mode described in the user manual under the section '16.5.8 CAN controller self-tests', but it doesn't work.

I tried these NXP examples described on the NXP knowledgebase and used the NXP example code (can_self_test codes). All pin configurations run OK, and all CAN bus configuration and CAN bus message frames run OK too (controlled one by one). But inside the CAN1_Send func after this step:

CANx->CMR = 0x41;

the error flag is set. Nonetheless, CAN1_Send returns SUCCESS.

In fact, this error status means 'bus off error'. 'bus off error' means there was a frame error and CAN controller error. I test Data frame and CAN controller. It works.

I use an RS-232 cable for connecting CAN1 and CAN2. For self testing, I use CAN1.

هل كانت مفيدة؟

المحلول

I'm not familiar with that CAN controller, but that behaviour doesn't surprise me. If you are performing a standalone test, then although you correctly receive the message you sent, because there are no other nodes on the bus, the message will go unacknowledged. The controller will retry for a while before entering the error states described in sections 6 and 7 of the CAN spec

نصائح أخرى

I had the same problem here using an LPC1788 and the problem was related with a wrong CPU clock setup. I wrongly setup the CPU to operate at 96 MHz and I (also wrong) consider that CPU was running in 100 MHz. In this scenario the CAN baudrate configuration was inconsistent, and the CAN module failed to transmit any message. Then when I fixed the CPU clock configurations the problem was solved.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top