dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS [solved]

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

Moderator: Benj

User avatar
celebriums
Posts: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS [solved]

Postby celebriums » Mon Mar 05, 2018 5:16 pm

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.4 KiB) Downloaded 37 times
dsPIC33EP128MC506_Not_Read.fcfx
(131.13 KiB) Downloaded 35 times
dsPIC33EP256MU806_20180228_work.fcfx
(106.45 KiB) Downloaded 38 times
Last edited by celebriums on Fri Apr 20, 2018 4:09 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 13946
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4224 times
Been thanked: 3979 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby Benj » Fri Mar 16, 2018 5:59 pm

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.php?title=One_second_LED_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.
These users thanked the author Benj for the post:
celebriums (Wed Mar 28, 2018 9:24 pm)
Rating: 5.88%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1068
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 330 times
Been thanked: 537 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby QMESAR » Tue Mar 27, 2018 7:05 pm

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.96 KiB) Viewed 2805 times
These users thanked the author QMESAR for the post (total 2):
kersing (Tue Mar 27, 2018 9:37 pm) • celebriums (Wed Mar 28, 2018 8:59 pm)
Rating: 11.76%
 

User avatar
celebriums
Posts: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Wed Mar 28, 2018 9:13 pm

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: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Wed Mar 28, 2018 9:27 pm

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.php?title=One_second_LED_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: 1869
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 525 times
Been thanked: 1037 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby kersing » Wed Mar 28, 2018 10:56 pm

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: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Wed Mar 28, 2018 11:19 pm

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: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Tue Apr 03, 2018 11:30 am

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 38 times
Last edited by celebriums on Tue Apr 03, 2018 2:53 pm, edited 1 time in total.

User avatar
LeighM
Matrix Staff
Posts: 1749
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 414 times
Been thanked: 578 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby LeighM » Tue Apr 03, 2018 2:10 pm

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);
These users thanked the author LeighM for the post:
celebriums (Tue Apr 03, 2018 2:35 pm)
Rating: 5.88%
 

User avatar
celebriums
Posts: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Tue Apr 03, 2018 2:32 pm

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 26 times

User avatar
LeighM
Matrix Staff
Posts: 1749
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 414 times
Been thanked: 578 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby LeighM » Tue Apr 03, 2018 3:46 pm

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

Code: Select all

C1CFG2 = 0x06DA;

User avatar
celebriums
Posts: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Tue Apr 03, 2018 4:21 pm

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 26 times

User avatar
celebriums
Posts: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Tue Apr 03, 2018 5:22 pm

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 28 times

User avatar
LeighM
Matrix Staff
Posts: 1749
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 414 times
Been thanked: 578 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby LeighM » Wed Apr 04, 2018 11:06 am

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
(71.1 KiB) Downloaded 26 times

User avatar
celebriums
Posts: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Wed Apr 04, 2018 3:10 pm

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 26 times

User avatar
LeighM
Matrix Staff
Posts: 1749
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 414 times
Been thanked: 578 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby LeighM » Thu Apr 05, 2018 12:23 pm

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: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Thu Apr 05, 2018 1:19 pm

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

User avatar
celebriums
Posts: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Thu Apr 05, 2018 1:20 pm

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: 1749
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 414 times
Been thanked: 578 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby LeighM » Thu Apr 05, 2018 2:17 pm

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: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Thu Apr 05, 2018 2:55 pm

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.4 KiB) Downloaded 24 times
dsPIC33EP128MC506Remote.fcfx
(134.43 KiB) Downloaded 24 times
Last edited by celebriums on Thu Apr 05, 2018 4:38 pm, edited 1 time in total.

User avatar
celebriums
Posts: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Thu Apr 05, 2018 3:57 pm

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 25 times

User avatar
LeighM
Matrix Staff
Posts: 1749
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 414 times
Been thanked: 578 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby LeighM » Fri Apr 06, 2018 8:48 am

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: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Fri Apr 06, 2018 10:06 am

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.4 KiB) Downloaded 26 times
dsPIC33EP128MC506_Only_Send.fcfx
(11.05 KiB) Downloaded 28 times

User avatar
LeighM
Matrix Staff
Posts: 1749
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 414 times
Been thanked: 578 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby LeighM » Fri Apr 06, 2018 10:48 am

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: 92
Joined: Sun Sep 25, 2016 3:50 pm
Has thanked: 49 times
Been thanked: 26 times
Contact:

Re: dsPIC33EP128MC506, dsPIC33EP32MC502 and dsPIC33EP256MU806 CANBUS problem

Postby celebriums » Fri Apr 06, 2018 12:18 pm

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.