CAN Extended ID

Moderator: Benj

greenbanner
Posts: 5
Joined: Thu Apr 07, 2011 9:59 am
Has thanked: 2 times

CAN Extended ID

Postby greenbanner » Thu Jun 13, 2013 1:50 pm

I see that there is a proposal to provide extended ID mode for the CAN module in Flowcode v5 for PIC.
Is this available as a Beta version?
I am using the 18F4680

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

Re: CAN Extended ID

Postby Benj » Thu Jun 13, 2013 5:04 pm

Hello,

The CAN2 component should allow you to use extended IDs in Flowcode v5.
These users thanked the author Benj for the post:
greenbanner (Mon Jun 24, 2013 12:23 pm)
Rating: 5.56%
 

greenbanner
Posts: 5
Joined: Thu Apr 07, 2011 9:59 am
Has thanked: 2 times

Re: CAN Extended ID

Postby greenbanner » Thu Jun 13, 2013 11:30 pm

Thanks for the prompt reply.
I had missed this but was obvious as it was titled 'Extended CAN', sorry.

Having tried it out I have found that unlike the CAN module the CAN2 doesn't have a box to use 'Internal CAN' with the PIC.
I am also looking to set the rate at 50kbps.
Is there a method for configuring this?

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

Re: CAN Extended ID

Postby Benj » Fri Jun 14, 2013 3:11 pm

Hello,

The baud rate and internal/external can be overridden by using code customization on the defines section of the CAN2 component.

Code: Select all

#define INTERNAL_CAN_ENABLE      %b


is changed to this

Code: Select all

#define INTERNAL_CAN_ENABLE      1


and

Code: Select all

#define MX_CAN_BAUD1_1         %h
#define MX_CAN_BAUD2_1         %i
#define MX_CAN_BAUD3_1         %j


is changed to this

Code: Select all

#define MX_CAN_BAUD1_1         x
#define MX_CAN_BAUD2_1         y
#define MX_CAN_BAUD3_1         z


where x,y and z are your new baud values. If you search Google for "microchip can baud calculator" then you get some nice pages which should help to you work out what is needed.
These users thanked the author Benj for the post:
greenbanner (Mon Jun 24, 2013 12:23 pm)
Rating: 5.56%
 

greenbanner
Posts: 5
Joined: Thu Apr 07, 2011 9:59 am
Has thanked: 2 times

Re: CAN Extended ID

Postby greenbanner » Mon Jun 24, 2013 12:28 pm

Hi
Not sure if my last reply was sent.
I am still having difficulties using the CAN2 Flowcode component for a 18F4680 PIC.
The problem is that I only get Sandard CAN identifier not extended.
I am using the SetTx ExtIDAsFull macro with
id3=SIDH
id2=SIDL
id1=EIDH
id0=EIDL

Can you provide a little more information regarding the structure of id3-id0 to ensure I am configuring the internal CAN component correctly.

greenbanner
Posts: 5
Joined: Thu Apr 07, 2011 9:59 am
Has thanked: 2 times

Re: CAN Extended ID

Postby greenbanner » Mon Jun 24, 2013 2:38 pm

OK, I have managed to get extended CAN ID and sending correct data bytes but now but things just don't seemed to compute addressing wise.

I have deduced that in SetTxExtIDAsFull(buffer,id3,id2,id1,id0)
that id0 is the SIDL byte with bit3 being the IDE bit (set to 1 for extended addressing)

If all the other bits of id1,2 & 3 are set to zero I get Extended Address 000008h?
I have deduced the following which may be of some help;
that id2 is EIDL in that if bit0 is set then the Extended Address is 000009h (as expected with offset of 8h )
that id3 is EIDH in that if bit0 is set then Extended Address is 000808h (expected 000108 with offset of 8h )
if bit1 of id3 (EIDH) is set then Extended Address is 000108h
that id1 is SIDH in that if bit3 is set then Extended Address is 1000008h (as expected with offset of 8h )
if bit0 of SIDL is set then Extended Address is 010008h (as expected with offset of 8h )

Could it be that bit3 of id2 (EIDL) is being set by mistake for the IDE bit (this would give rise to the address 000008h)?

There also appears to be some bit swapping in id3 (EIDH).