DS PIC ECIO CAN bug? Or am I missing something?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Chris_MIRA
Posts: 186
Joined: Wed Jan 23, 2013 3:43 pm
Has thanked: 2 times
Been thanked: 21 times
Contact:

DS PIC ECIO CAN bug? Or am I missing something?

Postby Chris_MIRA » Thu Oct 08, 2015 1:15 pm

Hi,
Im using the attached test code to send a can signal using the ECIO DS pic. There appear to be two problems, the first is that the actual board rate generated is half that of the rate assigned in FC (e.g. I need to assign 1000 in Properties Bus rate to get a received CAN message at 500 b).

The next problem is that the Tx id address actually sent remains 1 regardless of the number set in the code, I have tried altering the address and the method of setting it (e.g SET TX ID simple or SET TXID)
Am I missing something or is this a bug?

Regards,
Chris
Attachments
TESTFC File.fcfx
(7.54 KiB) Downloaded 149 times

Chris_MIRA
Posts: 186
Joined: Wed Jan 23, 2013 3:43 pm
Has thanked: 2 times
Been thanked: 21 times
Contact:

Re: DS PIC ECIO CAN bug? Or am I missing something?

Postby Chris_MIRA » Mon Oct 12, 2015 9:22 am

Hi,
Has anyone got any help on this please? Is it a bug?

regards,
Chris

User avatar
LeighM
Matrix Staff
Posts: 1962
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 475 times
Been thanked: 674 times
Contact:

Re: DS PIC ECIO CAN bug? Or am I missing something?

Postby LeighM » Mon Oct 12, 2015 2:22 pm

Hi Chris,

Yes, looks like a bug, in line 1650 of PIC16BIT_CAL_CAN.c

Code: Select all

   MX_MEMBUF_X[buffer][0] = (MX_CAN_TXB0ID_X << 2) & 0b0001111111111100;

This is using the component property value, MX_CAN_TXB0ID_X, rather than the macro parameters.

You would probably be better using SetTxIdent macro,
although it looks like there is a bug in that too, on line 2183

Code: Select all

   MX_MEMBUF_X[buffer][0] = (id << 2) & 0b0001111111111100;

I think that should be shifting 5 bits, not 2

Code: Select all

   MX_MEMBUF_X[buffer][0] = id << 5;

Could you try it please? (I don't have hardware to hand at the moment)
Thanks
Leigh
ps. I'll have a look at the baud rate issue

kersing
Valued Contributor
Valued Contributor
Posts: 1894
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 541 times
Been thanked: 1058 times
Contact:

Re: DS PIC ECIO CAN bug? Or am I missing something?

Postby kersing » Mon Oct 12, 2015 5:59 pm

LeighM wrote:Yes, looks like a bug, in line 1650 of PIC16BIT_CAL_CAN.c

Code: Select all

   MX_MEMBUF_X[buffer][0] = (MX_CAN_TXB0ID_X << 2) & 0b0001111111111100;

This is using the component property value, MX_CAN_TXB0ID_X, rather than the macro parameters.


Oops, my bad.

LeighM wrote:You would probably be better using SetTxIdent macro,
although it looks like there is a bug in that too, on line 2183

Code: Select all

   MX_MEMBUF_X[buffer][0] = (id << 2) & 0b0001111111111100;

I think that should be shifting 5 bits, not 2

Code: Select all

   MX_MEMBUF_X[buffer][0] = id << 5;



Why would you want to shift 5 bits? According to the data sheet page 381, ECAN™ MESSAGE BUFFER WORD 0:
Microchip wrote:bit 12-2 SID<10:0>: Standard Identifier bits


So a shift of two bits looks right to me.

LeighM wrote:ps. I'll have a look at the baud rate issue


I recall having added code to the CAN CAL component to fix a silicon bug. For some devices CnCTRL1bits.CANCKS works in reverse (so setting it to 1 is the setting listed in the data sheet for 0 v.v.) I know this bug applies to the chip on ECIO16, may-be the work around is not triggered for this device? (Or something completely different might be wrong)
These users thanked the author kersing for the post (total 2):
LeighM (Tue Oct 13, 2015 8:20 am) • Benj (Tue Oct 13, 2015 10:37 am)
Rating: 10.53%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Chris_MIRA
Posts: 186
Joined: Wed Jan 23, 2013 3:43 pm
Has thanked: 2 times
Been thanked: 21 times
Contact:

Re: DS PIC ECIO CAN bug? Or am I missing something?

Postby Chris_MIRA » Tue Oct 13, 2015 2:05 pm

Errr ...
First, thanks for looking into this :-)
Im afraid Im a little confused as to what the fix is and how to implement it?
How do I get to the right place (presumably in the FC6 CAN CAl library file?)
And what do I actually correct?

Regards,
Chris

User avatar
LeighM
Matrix Staff
Posts: 1962
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 475 times
Been thanked: 674 times
Contact:

Re: DS PIC ECIO CAN bug? Or am I missing something?

Postby LeighM » Tue Oct 13, 2015 2:37 pm

Hi Chris,
Looks like you should be OK with the SetTxIdent macro
Leigh

Chris_MIRA
Posts: 186
Joined: Wed Jan 23, 2013 3:43 pm
Has thanked: 2 times
Been thanked: 21 times
Contact:

Re: DS PIC ECIO CAN bug? Or am I missing something?

Postby Chris_MIRA » Wed Oct 14, 2015 7:50 am

Thanks Leigh,
Ill try that! Will you please let me know when the bud is fixed?

Regards Chris