Hello all,
I am using a twr-k20d72m board and started to try the flexCAN example with MQX 3.8.1 and CW 10.2.
CW builds the example successfully but I can not see any activity on PTA12 pin 42 on the PK20DX256VLL7 using an oscilloscope. The terminal output is:
*********FLEXCAN TEST PROGRAM.********* Message format: Standard (11 bit id) Message buffer 0 used for Tx and Rx. Interrupt Mode: Enabled Operation Mode: TX and RX --> Normal *************************************** selected frequency (Kbps) is: 125 Data length: 1 FLEXCAN reset. result: 0x0 FLEXCAN initilization. result: 0x0 FLEXCAN mode selected. result: 0x0 FLEXCAN global mask. result: 0x0 FLEXCAN Error ISR install, result: 0x0 FLEXCAN Bus off ISR install, result: 0x0 FLEXCAN error interrupt enable. result: 0x0 FLEXCAN rx remote mailbox initialization. result: 0x0 FLEXCAN rx mailbox initialization. result: 0x0 FLEXCAN mailbox activation. result: 0x0 FLEXCAN RX ISR install. result: 0x0 FLEXCAN RX remote ISR install. result: 0x0 FLEXCAN tx remote mailbox initialization. result: 0x0 FLEXCAN tx mailbox initialization. result: 0x0 FLEXCAN tx mailbox activation. result: 0x0 FLEXCAN TX ISR install. result: 0x0 FLEXCAN TX remote ISR install. result: 0x0 FLEXCAN started. result: 0x0 Data transmit: 0 Data transmit: 1 FLEXCAN tx update message. result: 0x0 Data transmit: 2 FLEXCAN tx update message. result: 0x0 Data transmit: 3 FLEXCAN tx update message. result: 0x0 Data transmit: 4 FLEXCAN tx update message. result: 0x0
When I configure the CAN in loopback mode it seems to work but still I can not see any activity on the pins with the oscillosope. For the loopback I use the code from another forum post. Re: Flexcan example on tower K60
*********FLEXCAN TEST PROGRAM.********* Message format: Standard (11 bit id) Message buffer 0 used for Tx and Rxion. result: 0x0 FLEXCAN mailbox activation. result: 0x0 FLEXCAN RX ISR install. result: 0x0 FLEXCAN RX remote ISR install. result: 0x0 FLEXCAN tx remote mailbox initialization. result: 0x0 FLEXCAN tx mailbox initialization. result: 0x0 FLEXCAN tx mailbox activation. result: 0x0 FLEXCAN TX ISR install. result: 0x0 FLEXCAN TX remote ISR install. result: 0x0 FLEXCAN started. result: 0x0 Data transmit: 0 Received data: 0x0 ID is: 0x123 DLC is: 0x1 Data transmit: 1 FLEXCAN tx update message. result: 0x0 Received data: 0x1 ID is: 0x123 DLC is: 0x1
Any help much appreciated.
Best regards,
Christos
Solved! Go to Solution.
Hi Christos
The CAN protocol requires the CAN transmitter to verify itself whenever it transmits. While transmitting on the Tx pin, it also listens on the Rx pin to ensure it receives the same data being transmitted. If it doesn't, then it stops transmitting.
Therefore, if you are not using a CAN PHY that loops the Tx back to Rx, then you need to short the Tx pin on your Tower system to the Rx pin. Otherwise, you won't see any data transmitting on Tx.
And if that isn't enough to help you, ensure the pin mux for your CAN pins are set for the CAN peripheral. The pin mux is set in the PORTx_PCR registers.
Hi Christos
The CAN protocol requires the CAN transmitter to verify itself whenever it transmits. While transmitting on the Tx pin, it also listens on the Rx pin to ensure it receives the same data being transmitted. If it doesn't, then it stops transmitting.
Therefore, if you are not using a CAN PHY that loops the Tx back to Rx, then you need to short the Tx pin on your Tower system to the Rx pin. Otherwise, you won't see any data transmitting on Tx.
And if that isn't enough to help you, ensure the pin mux for your CAN pins are set for the CAN peripheral. The pin mux is set in the PORTx_PCR registers.
Hi Derek,
Thank you very much for your reply. That makes sense now, as you say it needs the RX because it needs to determine the bus arbitration status. I believe this must be the problem indeed.
I have a TWR-IND-IO board which has CAN PHY. I will give that a try ASAP and mark your answer as correct upon success.
Cheers,
Christos
Hi Derek,
Thank you very much for your help. I have actually have solved the problem and it was indeed what you advised the CAN PHY was NOT connected.
Just in case someone else has the same issue these are the modification I had to do to make the TWR-K20D72M work with the TWR-IND-IO.
Once again thank you very much.
Best regards,
Christos