Internal CAN-BUS
Moderator: Benj
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Internal CAN-BUS
I have a problem; internal CAN-BUS doesn't work well.
I have a project with PIC 18F2580 it works with crystal 16MHz.
When I try to send any packet it seems like wrong boud rate (I don't know exactly) and I don't see the packet.
But external CAN-BUS with MCP2515 on 20MHz works good.
How can I solve problem with internal CAN-BUS?
And one more: do both CAN-BUS (internal and external as two components) work together?
I have a project with PIC 18F2580 it works with crystal 16MHz.
When I try to send any packet it seems like wrong boud rate (I don't know exactly) and I don't see the packet.
But external CAN-BUS with MCP2515 on 20MHz works good.
How can I solve problem with internal CAN-BUS?
And one more: do both CAN-BUS (internal and external as two components) work together?
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Internal CAN-BUS
Please attach a flowchart file (not screen shots) with problems so settings of the controller and components can be verified in case that might be an issue.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Internal CAN-BUS
As I see, FC6 makes the same code for diffident crystals (16 and 20 MHz):
Code: Select all
//setup CNF and control registers
FC_CAN_SPI_CAN_Config_2(FCV_0e702_can2__CAN_REQOP_CONFIG);
FC_CAN_SPI_CAN_Write_2(FCV_0e702_can2__CAN_CNF1, 1);
FC_CAN_SPI_CAN_Write_2(FCV_0e702_can2__CAN_CNF2, 209);
FC_CAN_SPI_CAN_Write_2(FCV_0e702_can2__CAN_CNF3, 3);
//setup CNF and control registers
FC_CAN_SPI_CAN_Config_1(FCV_0e701_can1__CAN_REQOP_CONFIG);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_CNF1, 1);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_CNF2, 209);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_CNF3, 3);
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Internal CAN-BUS
Hi, I cannot check the Flowcode file just now, but just a comment on the C code...
That looks like the external CAN code, where the crystal freq is set in the External CAN component.
You will need to look for other similarly named defines in the C code for the internal CAN.
I'll be better able to help on Monday.
That looks like the external CAN code, where the crystal freq is set in the External CAN component.
You will need to look for other similarly named defines in the C code for the internal CAN.
I'll be better able to help on Monday.
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Internal CAN-BUS
Thanks!
I have checked with only one internal channel - it doesn't work on my project. Something is going from MCP2551 but I can't catch any pocket/ I'd tried standard (100,125,500) and another (95,238) boudrate.
And the same flowchat from FC5 - works fine.
When I changed crystal for PIC from 16 to 20 MHz and rebuilt the project (with this changes) it stared work with 2 CAN interfaces.
I have checked with only one internal channel - it doesn't work on my project. Something is going from MCP2551 but I can't catch any pocket/ I'd tried standard (100,125,500) and another (95,238) boudrate.
And the same flowchat from FC5 - works fine.
When I changed crystal for PIC from 16 to 20 MHz and rebuilt the project (with this changes) it stared work with 2 CAN interfaces.
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Internal CAN-BUS
And a new problem:
How can I change boudrate for internal can on this flowchat?
At this case it still sends packets on 125kbps. If I change boudrate to 500kbps by standard form (without removing C-form) - I can't catch any packets on 500,125, 95.238 kbps.
p.s. External CAN-BUS sends packets on 95.238 kbps (as I need).
How can I change boudrate for internal can on this flowchat?
At this case it still sends packets on 125kbps. If I change boudrate to 500kbps by standard form (without removing C-form) - I can't catch any packets on 500,125, 95.238 kbps.
p.s. External CAN-BUS sends packets on 95.238 kbps (as I need).
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Internal CAN-BUS
Hi,
To customize the internal CAN baud rate you will need to do something like this ...
Hope that helps,
Leigh
To customize the internal CAN baud rate you will need to do something like this ...
Code: Select all
// Request config mode.
cancon = MX_CAN_REQOP_CONFIG;
while( (canstat & MX_CAN_OP_MODE_BITS) != MX_CAN_REQOP_CONFIG );
// change the baud rate registers
brgcon3 = 3;
brgcon2 = 209;
brgcon1 = 1;
// Request normal mode.
cancon = MX_CAN_REQOP_NORMAL;
while( (canstat & MX_CAN_OP_MODE_BITS) != MX_CAN_REQOP_NORMAL );
Leigh
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Internal CAN-BUS
Thanks!
I will check it.
Is it only one way to sen baud rate through additional С code, or FC6 has another options as it was in FC5?
I will check it.
Is it only one way to sen baud rate through additional С code, or FC6 has another options as it was in FC5?
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Internal CAN-BUS
With FC6 only the four standard speeds are selectable in the component, the config registers are not exposed for modification
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Internal CAN-BUS
it's sad. It is step to uncomfortable using the FC.LeighM wrote:With FC6 only the four standard speeds are selectable in the component, the config registers are not exposed for modification
And thanks again, your code works fine!