dspic33ep128gm604 CAN BUS Problems
Moderator: Benj
dspic33ep128gm604 CAN BUS Problems
Hello,
I´m working with a dsPIC33EP128GM604 and I have Problems with the CAN BUS component (CAN Internal 1 and CAN INternal 2).
Internal CAN 1 sends correct Data and correct ID when the Data and the ID in the Component "set tx data" are fix. But when i use variables for the data and the ID, then the received data on my CANalyzer are wrong.
Internal CAN 2 always sends wrong Data and wrong ID.
For example:
ID 0xa8
Data 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa
=> should be send (with component "set tx data")
=> but i recieve:
ID 0x00
DLC = 0
(see picture in atachments)
I´m working with a dsPIC33EP128GM604 and I have Problems with the CAN BUS component (CAN Internal 1 and CAN INternal 2).
Internal CAN 1 sends correct Data and correct ID when the Data and the ID in the Component "set tx data" are fix. But when i use variables for the data and the ID, then the received data on my CANalyzer are wrong.
Internal CAN 2 always sends wrong Data and wrong ID.
For example:
ID 0xa8
Data 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa
=> should be send (with component "set tx data")
=> but i recieve:
ID 0x00
DLC = 0
(see picture in atachments)
- Attachments
-
- dsPIC33_CAN_test.fcfx
- (19.68 KiB) Downloaded 544 times
-
- CANalyzer.JPG (29.78 KiB) Viewed 23125 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: dspic33ep128gm604 CAN BUS Problems
Hello,
Many thanks for letting us know.
We are aware of a problem with Internal CAN channel 2. I'm investigating it but currently there is a lot on my plate.
viewtopic.php?f=63&t=20406&p=90469
How urgent is the project for you. I can jump back on this later today if it's urgent.
Many thanks for letting us know.
We are aware of a problem with Internal CAN channel 2. I'm investigating it but currently there is a lot on my plate.
viewtopic.php?f=63&t=20406&p=90469
How urgent is the project for you. I can jump back on this later today if it's urgent.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: dspic33ep128gm604 CAN BUS Problems
Hello Benj,
thanks for your answer.
It would be great if there was a solution to this problem soon, as I am under some time pressure and have not progressed for a few days.
In my project, i have to manipulate data in a CAN network, so the 2nd CAN channel is necessary for me.
Thanks for your help in forward
Best regards
Daniel
thanks for your answer.
It would be great if there was a solution to this problem soon, as I am under some time pressure and have not progressed for a few days.
In my project, i have to manipulate data in a CAN network, so the 2nd CAN channel is necessary for me.
Thanks for your help in forward
Best regards
Daniel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: dspic33ep128gm604 CAN BUS Problems
Thanks Daniel,
I'll have an investigation for you this afternoon and see where I get.
Edit: I have now done a bit of testing and it looks like both internal CAN channels are transmitting data ok. The problem seems to be to do with receiving.
Here I have CH1 sending ID1 with Data bytes all 1s and CH2 sending ID2 with Data bytes all 2s.
I'll have an investigation for you this afternoon and see where I get.
Edit: I have now done a bit of testing and it looks like both internal CAN channels are transmitting data ok. The problem seems to be to do with receiving.
Here I have CH1 sending ID1 with Data bytes all 1s and CH2 sending ID2 with Data bytes all 2s.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: dspic33ep128gm604 CAN BUS Problems
Hello Benj,
ok, can you send me your current CAL_CAN file?
With the CAL_CAN file from your post in the other chat is transmitting with Ch1 ok, Ch2 sends wrong data and 2 different ID`s and I send only one ID.
The ID I want to send is 0xa7...but with the CANalyzer I see ID 0x280 and 0xFC3FC0x...
ok, can you send me your current CAL_CAN file?
With the CAL_CAN file from your post in the other chat is transmitting with Ch1 ok, Ch2 sends wrong data and 2 different ID`s and I send only one ID.
The ID I want to send is 0xa7...but with the CANalyzer I see ID 0x280 and 0xFC3FC0x...
- Attachments
-
- CANalyzer_v2.JPG (24.51 KiB) Viewed 23106 times
-
- dsPIC33_CAN_test.fcfx
- (19.66 KiB) Downloaded 537 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: dspic33ep128gm604 CAN BUS Problems
Hello,
Here's the current CAL file.
Here's the current CAL file.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
Re: dspic33ep128gm604 CAN BUS Problems
Hi All,
Just my 2 cents from a past problem very similar to this is that if you look at your CANalyser you will notice you see 1 extended messgage ID with a DLC (Data length code )of 15 this is a PC CANalyser Driver issue specially if you use win 8 or 10 ,There is no way the PIC can send a DLC of 15
I had this issue and it drove me nuts until I found the correct driver(this was with PeakCAN though
I not saying this is the issue however the DLC of 15 is suspicious .
Just my 2 cents from a past problem very similar to this is that if you look at your CANalyser you will notice you see 1 extended messgage ID with a DLC (Data length code )of 15 this is a PC CANalyser Driver issue specially if you use win 8 or 10 ,There is no way the PIC can send a DLC of 15
I had this issue and it drove me nuts until I found the correct driver(this was with PeakCAN though
I not saying this is the issue however the DLC of 15 is suspicious .
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
Re: dspic33ep128gm604 CAN BUS Problems
Hi QMESAR,
thanks for your help. You`re right, dlc 15 can not be, but i think the CANalyzer shows this because the data from the pic are not plausible.
(i`m using Vector CANalyzer)
With the last CAL_CAN file from benj is transmitting ok now. The Problem now is the receive part...
Best regards
Daniel
thanks for your help. You`re right, dlc 15 can not be, but i think the CANalyzer shows this because the data from the pic are not plausible.
(i`m using Vector CANalyzer)
With the last CAL_CAN file from benj is transmitting ok now. The Problem now is the receive part...
Best regards
Daniel
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: dspic33ep128gm604 CAN BUS Problems
Hi
Can I suggest that for the receive buffer you try the property setting of "Use Mask and Filter" and set the Mask and Filter values manually.
I suspect that the "Accept All" does not work.
Can I suggest that for the receive buffer you try the property setting of "Use Mask and Filter" and set the Mask and Filter values manually.
I suspect that the "Accept All" does not work.
Re: dspic33ep128gm604 CAN BUS Problems
Hi LeighM,
you`re right, it works when i set the mask and filter values manually.
The next problem is the ID type setting in CAN 2.
When "standard & extended ID" is set, i can not compile (see attachment).
=> Some ")" were missing in the CAL_CAN file.
I fixed this, but the funktion is still not working correctly. There is a issue when I receive standard and extended ID`s on CAN 1 and want to send this ID`s on CAN 2.
Could you help me again please?
Thanks and regards
Daniel
you`re right, it works when i set the mask and filter values manually.
The next problem is the ID type setting in CAN 2.
When "standard & extended ID" is set, i can not compile (see attachment).
=> Some ")" were missing in the CAL_CAN file.
I fixed this, but the funktion is still not working correctly. There is a issue when I receive standard and extended ID`s on CAN 1 and want to send this ID`s on CAN 2.
Could you help me again please?
Thanks and regards
Daniel
- Attachments
-
- comp.JPG (35.63 KiB) Viewed 23007 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: dspic33ep128gm604 CAN BUS Problems
Thanks for the spot.
Can you try this fixed CAL file, it should now compile OK.
What function is not working?
Could you send the program that demonstrates the issue?
Can you try this fixed CAL file, it should now compile OK.
What function is not working?
Could you send the program that demonstrates the issue?
- Attachments
-
- PIC16BIT_CAL_CAN.c
- (66.07 KiB) Downloaded 495 times
Re: dspic33ep128gm604 CAN BUS Problems
Hi LeighM,
thanks, compile is ok now.
In the atachement is a simple the program to demonstrate. CAN 1 should receive some messages (extended and also standard IDs) and send this on CAN 2.
regards
Daniel
thanks, compile is ok now.
In the atachement is a simple the program to demonstrate. CAN 1 should receive some messages (extended and also standard IDs) and send this on CAN 2.
regards
Daniel
- Attachments
-
- dsPIC33_CAN_test.fcfx
- (103.84 KiB) Downloaded 464 times
Re: dspic33ep128gm604 CAN BUS Problems
Hello Leigh,
with your CAL_CAN file, i can´t send any message with CAN2. Benj has already fixed this Problem and has sent me a new Version (in his post in this chat). In this file i added the missing ")". => see the atachement
Here is receiving and sending with both CAN ok, but only for standard ID`S and setting "only standard" ID type.
When the ID type is set to "standard and extended" for both Channels and I send with my CANalyzer a standard ID message on CAN 1, than the receiving is not ok. In my program i want to send the received message on CAN2. CAN2 sends then an extended ID (see atachement)
regards
Daniel
with your CAL_CAN file, i can´t send any message with CAN2. Benj has already fixed this Problem and has sent me a new Version (in his post in this chat). In this file i added the missing ")". => see the atachement
Here is receiving and sending with both CAN ok, but only for standard ID`S and setting "only standard" ID type.
When the ID type is set to "standard and extended" for both Channels and I send with my CANalyzer a standard ID message on CAN 1, than the receiving is not ok. In my program i want to send the received message on CAN2. CAN2 sends then an extended ID (see atachement)
regards
Daniel
- Attachments
-
- CANalyzer.JPG (23.44 KiB) Viewed 22968 times
-
- PIC16BIT_CAL_CAN.c
- (66.07 KiB) Downloaded 422 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: dspic33ep128gm604 CAN BUS Problems
Hi Daniel,
The component code is currently written such that the CAN channel either works in base frame format (11 bit ID), or extended frame format (29 bit ID) mode. Are you expecting both types on the same bus?
The component code is currently written such that the CAN channel either works in base frame format (11 bit ID), or extended frame format (29 bit ID) mode. Are you expecting both types on the same bus?
Re: dspic33ep128gm604 CAN BUS Problems
Hello Leigh,
yes i´m expecting both ID types on the same bus and have to send both types on CAN2.
That means I can´t do this with the current component?
Do you plan to change this?
regards
Daniel
yes i´m expecting both ID types on the same bus and have to send both types on CAN2.
That means I can´t do this with the current component?
Do you plan to change this?
regards
Daniel
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: dspic33ep128gm604 CAN BUS Problems
Hi Daniel,
Having looked at the CAL code it looks like a channel set to "standard & extended" should receive a standard ID message OK,
as the MIDE flag is set to 0. Although the GetRxIdent will most likely not return the expected ID.
Changing the code to support mixed receiving and sending will be quite a task, but we might be able to push it along,
it depends on what does actually work and how much more you need.
So, can we just summarize what you have so far...
Set both channels Id type to "standard": Receive standard id message on channel 1 and send standard id message on channel 2: OK
Set both channels Id type to "standard & extended": Receive extended id message on channel 1 and send extended id message on channel 2: OK ?
Set both channels Id type to "standard & extended": Receive standard id message on channel 1? Does CheckRx return true?
Do you need to receive and send on both channels? And does that work with standard IDs, if not extended IDs?
Leigh
Having looked at the CAL code it looks like a channel set to "standard & extended" should receive a standard ID message OK,
as the MIDE flag is set to 0. Although the GetRxIdent will most likely not return the expected ID.
Changing the code to support mixed receiving and sending will be quite a task, but we might be able to push it along,
it depends on what does actually work and how much more you need.
So, can we just summarize what you have so far...
Set both channels Id type to "standard": Receive standard id message on channel 1 and send standard id message on channel 2: OK
Set both channels Id type to "standard & extended": Receive extended id message on channel 1 and send extended id message on channel 2: OK ?
Set both channels Id type to "standard & extended": Receive standard id message on channel 1? Does CheckRx return true?
Do you need to receive and send on both channels? And does that work with standard IDs, if not extended IDs?
Leigh
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: dspic33ep128gm604 CAN BUS Problems
Hi Daniel,
I've got hold of some hardware (nicked off Ben and I've been testing sending and receiving between channel 1 and channel 2
All seems to be well as far as I can see.
I've successfully sent a standard ID message from one channel (set to "standard") and received it OK on the other channel set to "standard & extended"
I've fixed the GetRxIdent such that it uses the IDE flag from the received ID (rather than the component property mode)
So if you use the attached updated CAL file you will get the correct received message ID
The only thing we cannot do at present is dynamically change the transmit ID mode of a channel,
that's something I could have a look into, depending upon if you need it?
You made a comment earlier that you need to receive "standard" and "standard & extended" ID messages,
but send them on channel 2 as "standard & extended",
is that correct?
Leigh
I've got hold of some hardware (nicked off Ben and I've been testing sending and receiving between channel 1 and channel 2
All seems to be well as far as I can see.
I've successfully sent a standard ID message from one channel (set to "standard") and received it OK on the other channel set to "standard & extended"
I've fixed the GetRxIdent such that it uses the IDE flag from the received ID (rather than the component property mode)
So if you use the attached updated CAL file you will get the correct received message ID
The only thing we cannot do at present is dynamically change the transmit ID mode of a channel,
that's something I could have a look into, depending upon if you need it?
You made a comment earlier that you need to receive "standard" and "standard & extended" ID messages,
but send them on channel 2 as "standard & extended",
is that correct?
Leigh
- Attachments
-
- PIC16BIT_CAL_CAN.c
- (66.01 KiB) Downloaded 463 times
Re: dspic33ep128gm604 CAN BUS Problems
Hi Leigh,
many thanks for your help.
i have tested it, it works the way you say.
"The only thing we cannot do at present is dynamically change the transmit ID mode of a channel,
that's something I could have a look into, depending upon if you need it?"
=> That would be awesome
I`ve many projects with CAN networks in cars and often have to modify data from a control unit which receive the rest of the car. I seperate the bus for this, thats why i have to put through many messages (with standard IDs and also extended IDs) to the other channel.
In short I have to receive standard ID and extended ID on both Channels and send them as i received on the respective other channel. (CAN to CAN gateway)
I hope I could explain it reasonably well with my bad english
Many thanks in advance
Daniel
many thanks for your help.
i have tested it, it works the way you say.
"The only thing we cannot do at present is dynamically change the transmit ID mode of a channel,
that's something I could have a look into, depending upon if you need it?"
=> That would be awesome
I`ve many projects with CAN networks in cars and often have to modify data from a control unit which receive the rest of the car. I seperate the bus for this, thats why i have to put through many messages (with standard IDs and also extended IDs) to the other channel.
In short I have to receive standard ID and extended ID on both Channels and send them as i received on the respective other channel. (CAN to CAN gateway)
I hope I could explain it reasonably well with my bad english
Many thanks in advance
Daniel
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: dspic33ep128gm604 CAN BUS Problems
Hi Daniel,
You could force the sending of a standard ID with the following C code, used instead of the SetTxIdent
You could force the sending of a standard ID with the following C code, used instead of the SetTxIdent
Code: Select all
MX_MEMBUF_2[0][0] = (FCV_CAN_1_RX_ID_B0) << 2;
Re: dspic33ep128gm604 CAN BUS Problems
Hi Leigh,
everything works perfectly now!
i did the same with "MX_MEMBUF_1[0][0]" for sending on CAN 1.
And when ID > 0x7FF => i use the component "SetTxIdent"
Thank you very much for the your great support
regards
Daniel
everything works perfectly now!
i did the same with "MX_MEMBUF_1[0][0]" for sending on CAN 1.
And when ID > 0x7FF => i use the component "SetTxIdent"
Thank you very much for the your great support
regards
Daniel
Re: dspic33ep128gm604 CAN BUS Problems
Hello Leigh and Ben,
i have another Problem with the CAN BUS. In my project i have a CAN to CAN gateway. so i have to send on CAN 2 all messages which i recieved on CAN 1, and the same from CAN 2 to CAN 1.
If there are many messages on the BUS sometimes messages get lost. I use "RX Buffer 1". Do you think the Buffer size is to small or what do you think is the Problem? Do you have an idea?
best regards
Daniel
i have another Problem with the CAN BUS. In my project i have a CAN to CAN gateway. so i have to send on CAN 2 all messages which i recieved on CAN 1, and the same from CAN 2 to CAN 1.
If there are many messages on the BUS sometimes messages get lost. I use "RX Buffer 1". Do you think the Buffer size is to small or what do you think is the Problem? Do you have an idea?
best regards
Daniel