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

Post Reply
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?

Post by Chris_MIRA »

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 265 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?

Post by Chris_MIRA »

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

regards,
Chris

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

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

Post by LeighM »

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: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

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

Post by kersing »

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)
“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?

Post by Chris_MIRA »

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: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

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

Post by LeighM »

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?

Post by Chris_MIRA »

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

Regards Chris

Post Reply