dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS [solved]

An area to discuss 16-bit PIC specific problems and examples

Moderator: Benj

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS [solved]

Post by celebriums »

Hi Benj

When I send canbus with dsPIC33EP128MC506 and dsPIC33EP32MC502, I saw wrong values on the CANBUS analyzer. When I want to read the CANBUS data, I cannot read. I chose CANBUS component from TOOLS Menu.


With dsPIC33EP256MU806 only when SJW=4 and Sample=%80, I can read.

All of softwares at attachment.

Help Me Please.
Attachments
dsPIC33EP32MC502_not_read.fcfx
(129.31 KiB) Downloaded 130 times
dsPIC33EP128MC506_Not_Read.fcfx
(131.03 KiB) Downloaded 127 times
dsPIC33EP256MU806_20180228_work.fcfx
(106.44 KiB) Downloaded 130 times
Last edited by celebriums on Fri Apr 20, 2018 4:09 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 15149
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by Benj »

Hello Sadik,

Have you confirmed that your micro is running at the speed you think it is by doing a 1 second flasher test?
https://www.matrixtsl.com/wikiv7/index. ... ED_flasher

If the flasher test looks ok then can you tell us what values you are trying to send and the corresponding value the analyser is reading back.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1263
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by QMESAR »

Benj wrote: Have you confirmed that your micro is running at the speed you think it is by doing a 1 second flasher test?
Hi
I can only agree with what Ben is saying ,I looked at your FC charts and I see many configuration settings missing ,
In my opinion you should have a C function call in which you configure the mcu clock settings correctly as the build in menu only allows for
the PLL and the Clock source to be set however you need to set the indicated values in the attached in a C function call
1.JPG
1.JPG (40.95 KiB) Viewed 6874 times
Regards
QMESAR

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

Hello Qmesar

Thank you for your interest.

The problem is the following; dsPIC33EP256MU806 (70Mhz OSC.) Can read CANBUS data, but can not send it?
DsPIC33EP128MC502 (20Mhz Basic OSC) CAN be able to send CANBUS data but can not read it.
In the DSPIC33EP128MC506 (70 Mhz OSC), the values ​​change, starting to send meaningless values.
I'm surprised :) I will write again in more detail tomorrow.

How can I make the correct PLL settings for the DSPIC33EP series PLL? I have a 70MHz oscillator.

Thank you in advance for your help.

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

Benj wrote:Hello Sadik,

Have you confirmed that your micro is running at the speed you think it is by doing a 1 second flasher test?
https://www.matrixtsl.com/wikiv7/index. ... ED_flasher

If the flasher test looks ok then can you tell us what values you are trying to send and the corresponding value the analyser is reading back.
Thank you Benj, I will share the results of CANBUS ANALYZER tomorrow again.

kersing
Valued Contributor
Valued Contributor
Posts: 1994
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by kersing »

Have you checked the errata for this device? When working with one of the dsPIC33EP family devices and CAN a few years back I found there was a silicon error requiring a bit to be set to the opposite value of what the datasheet mentioned.

A quick check of the errata shows there are at least two CAN related issues in some of the silicon revisions of the dsPIC33EP128MC506.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

Thank you for your interest Kersing,
I agree with you that the core of MCUs are the same, dsPIC33EP256MU806 is more stable than the others, dsPIC33EP128MC506 and 206 are not stable. For this reason I tested different speeds.
The result is unfortunate frustration :D

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

Hello Everyone,
I have done with the DSPIC33EP128MC506, CANBUS communication problems, as follows. DATA02, DATA3, DATA4, DATA5, DATA6, DATA7 can not send the desired value.
OSC: EXT 70 Mhz, 1 second LED test is working correctly.

1. When sending CANBUS data, CAN ANALYZER results are as follows;

ID = 0x12FE1241 Correct (read data 0x12FE1241)
Buffer = 0
DLC = 8 Correct (read data = 8 )

DATA0 = 0x00 Correct (read data 0x00)
DATA1 = 0x00 Correct (read data 0x00)
DATA2 = 0x00 Incorrect (read data 0xFD)
DATA3 = 0x00 Incorrect (read data 0x12)
DATA4 = 0x00 Incorrect (read data 0x49)
DATA5 = 0x00 Incorrect (read data 0x08)
DATA6 = 0x00 Incorrect (read data 0x08)
DATA7 = 0x00 Incorrect (read data 0x04)

ID = 0x12FE1242 Correct (read data 0x12FE1242)
Buffer = 1
DLC = 8 Correct (read data = 8 )

DATA0 = 0x00 Correct, (read data 0x00)
DATA1 = 0x00 Correct, (read data 0x00)
DATA2 = 0x00 Incorrect, (read data 0xFD)
DATA3 = 0x00 Incorrect, (read data 0x12)
DATA4 = 0x00 Incorrect, (read data 0x49)
DATA5 = 0x00 Incorrect, (read data 0x08)
DATA6 = 0x00 Incorrect, (read data 0x08)
DATA7 = 0x00 Incorrect, (read data 0x08)


What can I do in this situation?
Attachments
EPS20180403_CW1.fcfx
(43.73 KiB) Downloaded 120 times
Last edited by celebriums on Tue Apr 03, 2018 2:53 pm, edited 1 time in total.

User avatar
LeighM
Matrix Staff
Posts: 2136
Joined: Tue Jan 17, 2012 10:07 am
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by LeighM »

Hi,
I think the bit rate might be slightly out.
Could you try this code in a C icon immediately following the CAN:Init call ...

Code: Select all

C1CTRL1bits.REQOP = REQOP_CONFIG;
while( C1CTRL1bits.OPMODE != REQOP_CONFIG);
C1CFG2 = 0x06DA;
C1CTRL1bits.REQOP = 0;
while(C1CTRL1bits.OPMODE != 0);

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

Hi,
I made the difference as well, but in this case CANBUS does not send data. Is the location of the C code correct?

C1CTRL1bits.REQOP = REQOP_CONFIG; /* Set the ECAN module for Configuration Mode before writing into the Baud
Rate Control Registers*/
while( C1CTRL1bits.OPMODE != REQOP_CONFIG);
C1CFG2 = 0x06DA;
C1CTRL1bits.REQOP = 0; "/* Put the ECAN Module into Normal Mode Operating Mode*/"
while(C1CTRL1bits.OPMODE != 0); /* Wait for the ECAN module to enter into Normal Operating Mode */
Attachments
EPS20180403_CW2.fcfx
(46.59 KiB) Downloaded 79 times

User avatar
LeighM
Matrix Staff
Posts: 2136
Joined: Tue Jan 17, 2012 10:07 am
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by LeighM »

Yes, looks OK.
Maybe remove all C icon code except ...

Code: Select all

C1CFG2 = 0x06DA;

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

LeighM

I think I found the problem and it's very interesting. The codes you wrote do not work.

SetTxData into the macro; CanData0, CanData1, variables are defined, and Flowcode do not mind, writing them for D0 and D1.

but

SetTxData into the macro; CanData2, CanData3, CanData4, CanData5, CanData6 and CanData7, variables are defined, and Flowcode do mind, writing them for D2,D3,D4,D5,D6 and D7.

When I delete the variables CanData0,1,2,3,4,5,6,7 the wrong files are recovering and working normally.

It is necessary to define variables in SetTxData. What can I do in this situation?
Attachments
EPS20180403_CW3.fcfx
(46.58 KiB) Downloaded 75 times

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

LeighM

There is another problem.
The ID value of the data from the CAN line; 0x12fe1240.
I read the CAN ID value and send it back to the CAN line. I check the accuracy of the CAN ID value.

but


I'm reading the wrong ID 0xBF1240 instead of 0x12FE1240.

I think there is also a problem with the GetRxData function.
Attachments
EPS20180403_CW4.fcfx
(44.27 KiB) Downloaded 67 times

User avatar
LeighM
Matrix Staff
Posts: 2136
Joined: Tue Jan 17, 2012 10:07 am
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by LeighM »

Hi,
I've found some issues with the ID, please try attached updated file (to go in Flowcode \CAL\PIC16BIT directory)
I cannot yet see what the problem might be with the data buffer.
Just to confirm... transmitted data 0 and data 1 are seen as OK with the analyzer, but not OK with 2 to 7?
Attachments
PIC16BIT_CAL_CAN.c
(68.77 KiB) Downloaded 69 times

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

Hi
I installed the PIC16BIT_CAL_CAN.c file, Flowcode \ CAL \ PIC16BIT.
. 0x1240 instead of 0x12FE1240. Unfortunately the code did not happen this time

I have another problem; Any new variable attachments can not send CAN data. Please watch the video.
https://youtu.be/aSsWfAiEVOw
https://youtu.be/vuNjZmqrj6Y
Attachments
EPS20180403_CW6.fcfx
(43.63 KiB) Downloaded 68 times

User avatar
LeighM
Matrix Staff
Posts: 2136
Joined: Tue Jan 17, 2012 10:07 am
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by LeighM »

Hi,
Thanks, but it is difficult to work out what is happening with the videos.
Do you have two dsPIC boards connected via CAN?
Would it be possible to just have one board transmit a message with a delay, and check first that transmit is OK with the analyser?

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

.
Last edited by celebriums on Thu Apr 05, 2018 1:22 pm, edited 1 time in total.

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

Hi
Yes, there are two devices connected via CAN. The 0x12FE1240 data belongs to a CANBUS device running correctly.

(0x1240) signal is the CANBUS signals of dsPIC33EP128MC506.

User avatar
LeighM
Matrix Staff
Posts: 2136
Joined: Tue Jan 17, 2012 10:07 am
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by LeighM »

Hi,
Is the correctly running CAN the dsPIC33EP256MU806?

As I have just created a test on hardware and have an MU806 transmitting correctly, although the bit rate is half what it should be,
I think that is possibly the silicon error that Kersing mentioned, but I've yet to check the errata datasheet.

So, the dsPIC33EP128MC506, is that transmitting OK, or not, or receiving OK or not?

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

The correct running dsPIC33EP128MC506 is the software for this product. (dsPIC33EP128mc506Remote). It can only send the right value.

As far as I understand; Silicon is not the fault, ( I'm sure about this )

As far as I understand; When I add a new variable,dsPIC33EP128MC506 can not read the data.

"So, the dsPIC33EP128MC506, is that transmitting OK, or not, or receiving OK or not?" I'll try it quickly and write the results soon.

Please consider dspic33EP128MC506Remote (trueversion). sorry
Attachments
dsPIC33EP128MC506Remote(trueversion).fcfx
(134.3 KiB) Downloaded 65 times
dsPIC33EP128MC506Remote.fcfx
(134.33 KiB) Downloaded 70 times
Last edited by celebriums on Thu Apr 05, 2018 4:38 pm, edited 1 time in total.

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

The dsPIC33EP128MC506, is that transmitting not OK.
Please watch this first mistake
videos link.
https://youtu.be/l0jE6yVKz_E
Attachments
dsPIC33EP128MC506_Only_Send.fcfx
(10.92 KiB) Downloaded 68 times

User avatar
LeighM
Matrix Staff
Posts: 2136
Joined: Tue Jan 17, 2012 10:07 am
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by LeighM »

Hi,
Thanks for doing that simple transmit test.
Do you have an oscilloscope to test the bit rate on the CAN bus? And also check both signals (+/-) are OK on the CAN bus?
Could you also try the code addition after the CAN:init and see what difference that makes? ...

Code: Select all

C1CFG2 = 0x06DA;

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

After adding C code; I have studied with Microchip CANBUS Analyzer, SALEAE Logic Analyzer, and Osilaskop, there is no slight change.

I can understand that there is, no hardware problem when dsPIC33EP128MC506TrueVersion is installed.

PCBs made in two different hardware in the hand give the same result. (CANBUS cabling in the form of a twist.)

Could you please check the link of the dsPIC33EP128MC506TrueVersion videos showing that it works correctly after installing the software?

Please watced video https://youtu.be/ohFD7m-CYYE

dsPIC33EP128MC506TrueVersion data sent by (CAN ID: 0x18FE1240)
dsPIC33EP128MC506_Only_Send data sent by (CAN ID: 0x12FE1200)

Notes:
Data sent by the other device(tester remote hardware have a dsPIC33EP128MC506TrueVersion software) on the line: (CAN ID 0x12FE1240)
Attachments
dsPIC33EP128MC506Remote(trueversion).fcfx
(134.3 KiB) Downloaded 69 times
dsPIC33EP128MC506_Only_Send.fcfx
(11.05 KiB) Downloaded 78 times

User avatar
LeighM
Matrix Staff
Posts: 2136
Joined: Tue Jan 17, 2012 10:07 am
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by LeighM »

So, just to confirm...
In the video, the "MC506 Only Send" is the only device sending on the CAN bus?
The analyser is catching two messages:
0x12FE1200 with the first two bytes correct (1,2), but the other 6 bytes incorrect
0x12FE1240 with wrong data (not 1,2,3,4,5,6,7,8)
Are both these messages coming from the MC506?
Does the analyser detect invalid messages?

It is very strange as the code works on my MU806 and I cannot yet see any differences between the devices in the datasheets.

User avatar
celebriums
Posts: 121
Joined: Sun Sep 25, 2016 3:50 pm
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Post by celebriums »

Hi LeighM,
There are just two devices on the CAN line. Each of them use dsPIC33EP128MC506.
The data of 0x12FE1240 is on the line continously and it doesn't send wrong data anyways.
0x12FE1240 with correct data (0,0,0,0,1,1,0,0). I never change this software, I just observe the CANBUS line.

The software at the beginning of the video is the software we have added the C code.

Step 1) 0x12FE1200 with the first two bytes correct (1,2), but the other 6 bytes incorrect (Correct) (Software: dsPIC33EP128MC506Send_Only)

Step 2) The second software that I have compiled at the video is dsPIC33EP128MC506TrueVersion. This software sends correct data.
It's CAN ID is 0x18FE1240.

I will incorporate the device which contain 806MCU and I will try that.

Post Reply