Jun 12, 2017
03:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 12, 2017
03:08 AM
Dear All,
I started to develop my code to manage a CAN communication. (I'm not an expert). I used "CAN_EXAMPLE_XMC45" example with loopback mode and everything works well.
Now I want to send packet from the physical pins: I disabled loopback, I assigned P1.12 and P1.13 as receive and trasmit pins and I inserted in a loop the function CAN_NODE_MO_Transmit(&Request_Node_LMO_01_Config);
First time I execute it I have success but using an oscilloscope I dont' measure anything. From the second time the function return busy status.
1) Which is my mistake? Why I don't see anything on tx pin?
2) Why do I have busy status?
PS I'm using xmc4500 relax kit
Regards
I started to develop my code to manage a CAN communication. (I'm not an expert). I used "CAN_EXAMPLE_XMC45" example with loopback mode and everything works well.
Now I want to send packet from the physical pins: I disabled loopback, I assigned P1.12 and P1.13 as receive and trasmit pins and I inserted in a loop the function CAN_NODE_MO_Transmit(&Request_Node_LMO_01_Config);
First time I execute it I have success but using an oscilloscope I dont' measure anything. From the second time the function return busy status.
1) Which is my mistake? Why I don't see anything on tx pin?
2) Why do I have busy status?
PS I'm using xmc4500 relax kit
Regards
- Tags:
- IFX
8 Replies
Jun 12, 2017
04:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 12, 2017
04:54 AM
Hi ermes,
Have you maybe took a look at the "CAN_TRANSMITTER" example which is located in XMCLibs examples? It´s fairly similar example, but it´s built using XMCLibs and on the XMC4500 Hexagon board. However, due to the fact it´s not exactly the same example, can you provide us with your project files? I could take a look what is not properly set. One thing to notice though, you should have a receiver board to have continuous CAN communication. Problem is that you transmit message on the CAN bus but there is no CAN node to receive message. I guess that once you transmit the CAN message you don´t see "CAN_NSR1_TXOK" status flag to be set to "1". For this reason I believe you see busy status. But first I would like to see your project files so I can see what maybe the issue.
Best regards;
Deni
Have you maybe took a look at the "CAN_TRANSMITTER" example which is located in XMCLibs examples? It´s fairly similar example, but it´s built using XMCLibs and on the XMC4500 Hexagon board. However, due to the fact it´s not exactly the same example, can you provide us with your project files? I could take a look what is not properly set. One thing to notice though, you should have a receiver board to have continuous CAN communication. Problem is that you transmit message on the CAN bus but there is no CAN node to receive message. I guess that once you transmit the CAN message you don´t see "CAN_NSR1_TXOK" status flag to be set to "1". For this reason I believe you see busy status. But first I would like to see your project files so I can see what maybe the issue.
Best regards;
Deni
Attachments are accessible only for community members.
Jun 12, 2017
05:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 12, 2017
05:22 AM
Hi Deni,
Thank you for your support.
I started with CAN_EXAMPLE_XMC45 because it is really easy to understand.
I attached a zip file with the project I am using. As you can see, I copied the example project and I disabled loopback mode.
I understand I receive a busy error while there isn't a CAN communication, but why I don't see anything with my oscilloscope? Also interrupt functions are not called after transmit.
I also tried to short Can1Tx with Can2Rx and Can1Rx with Can2Rx (ie P1.12 -> 1.5 and 1.13 -> 1.4) and the function inside interrupt (CAN_NODE_GetStatus(&Request_Node) & XMC_CAN_NODE_STATUS_LAST_ERROR_CODE) returns 1
Regards
Thank you for your support.
I started with CAN_EXAMPLE_XMC45 because it is really easy to understand.
I attached a zip file with the project I am using. As you can see, I copied the example project and I disabled loopback mode.
I understand I receive a busy error while there isn't a CAN communication, but why I don't see anything with my oscilloscope? Also interrupt functions are not called after transmit.
I also tried to short Can1Tx with Can2Rx and Can1Rx with Can2Rx (ie P1.12 -> 1.5 and 1.13 -> 1.4) and the function inside interrupt (CAN_NODE_GetStatus(&Request_Node) & XMC_CAN_NODE_STATUS_LAST_ERROR_CODE) returns 1
Regards
Jun 12, 2017
06:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 12, 2017
06:59 AM
Hi ermes,
hmmm, I noticed one "small", but very important detail when looking at the solution to your problem. Your board does not have a CAN transceiver. You can see that in the Board User Guide. For example. block diagram for your board:
and block diagram of the XMC4700/XMC4800 Relax kit with CAN transceiver in the blue circle.
So you can try to do implement a workaround (google "Is a CAN enabled microcontroller sufficient to drive a CAN bus") but you will have issues due to the no immunity to noise so it may not work, or it may work only on low speed/short distances. I would suggest to acquire some other board that has CAN transceiver already integrated. Of course you can always add CAN transceiver by yourself or you can try this quick&dirty hack that I mentioned.
Best regards,
Deni
hmmm, I noticed one "small", but very important detail when looking at the solution to your problem. Your board does not have a CAN transceiver. You can see that in the Board User Guide. For example. block diagram for your board:
and block diagram of the XMC4700/XMC4800 Relax kit with CAN transceiver in the blue circle.
So you can try to do implement a workaround (google "Is a CAN enabled microcontroller sufficient to drive a CAN bus") but you will have issues due to the no immunity to noise so it may not work, or it may work only on low speed/short distances. I would suggest to acquire some other board that has CAN transceiver already integrated. Of course you can always add CAN transceiver by yourself or you can try this quick&dirty hack that I mentioned.
Best regards,
Deni
Jun 12, 2017
08:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 12, 2017
08:25 AM
Hi Deni,
Of course I have an external can tranceiver! I want to decouple firmware problems from hardware problems.
My firmware works with loopback, but I don't measure anything with oscilloscope:
1) If can pin are disconnected from the tranceiver I see TxD = 3.3V and RxD = 0V
2) when I transmit nothing happens
3) the same if I connect the tranceiver
Could you suggest me some tests to do in order to exclude hardware or firmware problems?
Thank you
Of course I have an external can tranceiver! I want to decouple firmware problems from hardware problems.
My firmware works with loopback, but I don't measure anything with oscilloscope:
1) If can pin are disconnected from the tranceiver I see TxD = 3.3V and RxD = 0V
2) when I transmit nothing happens
3) the same if I connect the tranceiver
Could you suggest me some tests to do in order to exclude hardware or firmware problems?
Thank you
Jun 12, 2017
09:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 12, 2017
09:39 AM
Hi ermes,
Aaaa OK in that case...shall we continue with debugging then 😉
Can you please select P1.4 and P1.5 on the React Node side and try again? If this still doesn´t help, then please set the breakpoint right after transmit (right after following instruction: can_mo->can_mo_ptr-> MOCTR = CAN_MO_MOCTR_SETTXRQ_Msk | CAN_MO_MOCTR_SETTXEN0_Msk | CAN_MO_MOCTR_SETTXEN1_Msk and make an screenshot of your CAN_NSR registers for both nodes (TX and RX one). We will see what does the LEC bitfield states.
Best regards,
Deni
Aaaa OK in that case...shall we continue with debugging then 😉
I also tried to short Can1Tx with Can2Rx and Can1Rx with Can2Rx (ie P1.12 -> 1.5 and 1.13 -> 1.4). And this makes sense while the Board user manual for your board specifies the mentioned four pins as being available. However, in the example that you sent me, I see that another pins are selected for the receive node.
Can you please select P1.4 and P1.5 on the React Node side and try again? If this still doesn´t help, then please set the breakpoint right after transmit (right after following instruction: can_mo->can_mo_ptr-> MOCTR = CAN_MO_MOCTR_SETTXRQ_Msk | CAN_MO_MOCTR_SETTXEN0_Msk | CAN_MO_MOCTR_SETTXEN1_Msk and make an screenshot of your CAN_NSR registers for both nodes (TX and RX one). We will see what does the LEC bitfield states.
Best regards,
Deni
Jun 13, 2017
10:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 13, 2017
10:33 AM
Hi Deni,
Following your suggestion I double checked can tranceiver: there was a hardware bug. Now can communication works correctly.
Just a question: using the transmit function once the xmc starts to send tx packets. How Can I control sending period?
Thanks a lot Deni
Following your suggestion I double checked can tranceiver: there was a hardware bug. Now can communication works correctly.
Just a question: using the transmit function once the xmc starts to send tx packets. How Can I control sending period?
Thanks a lot Deni
Jun 21, 2017
01:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 21, 2017
01:47 AM
Hi Matteo,
I´m not exactly sure what do you assume with "controlling sending period", but I guess you think of some way to repeatedly send messages on CAN bus using transmit function. For this purpose, I would suggest using a timer with the wanted period and in the timer´s interrupt routine sending CAN message. You can also use the interrupt services of other peripherals for sure e.g upon receiving a message on SPI/UART you send the message over CAN bus (this was just an example, I don´t know your exact application).
Best regards,
Deni
I´m not exactly sure what do you assume with "controlling sending period", but I guess you think of some way to repeatedly send messages on CAN bus using transmit function. For this purpose, I would suggest using a timer with the wanted period and in the timer´s interrupt routine sending CAN message. You can also use the interrupt services of other peripherals for sure e.g upon receiving a message on SPI/UART you send the message over CAN bus (this was just an example, I don´t know your exact application).
Best regards,
Deni
Jun 26, 2017
03:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 26, 2017
03:09 AM
Hi,
normally a CAN controller transmits the message automatically until a valid acknowledgment is sent out from another node in CAN network. So connect a receiving node at your CAN network and it should work.
Regards
M.Schneiders
normally a CAN controller transmits the message automatically until a valid acknowledgment is sent out from another node in CAN network. So connect a receiving node at your CAN network and it should work.
Regards
M.Schneiders