ECIO40P16 and Internal CAN truble

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

Moderator: Benj

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Sun Aug 26, 2018 9:44 pm

Hi, I need some help, I can not communicate with a TJA 1050 CAN Controller with internal CAN1 and CAN2

I'm used to using Arduino and external SPI module and it worked well but I want to try an ECIO40P16 because it has 2 Internal ECAN.

I use the CAN (Internal, MCP2515) component in Flowcode 7

CAN1 TX ReMap to D0
CAN1 RX ReMap to B9

CAN2 TX ReMap to D6
CAN2 RX ReMap to D7

What are i doing wrong? Is there anything about RE Map I'm doing wrong? after what I understand, there is no port specifically dedicated to CAN or is it?

Hardware is:
1 ECIO40P16
2 TJA 1050 CAN Controller (Both of them are tested and work properly) https://www.ebay.com/itm/10PCS-TJA1050-CAN-Controller-Interface-Module-Bus-Driver/173365299265?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2060353.m2749.l2649


Thanks
Attachments
ECIO40P16_CAN_Test.fcfx
(20.83 KiB) Downloaded 51 times

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Sun Aug 26, 2018 10:32 pm

I found this but do not know if it is the same.
But could anyone explain this a little better. What file and what should I change? I need to go Bus Rate 500


Jay Dee wrote:Hi,
Same as with FC6, Using standard setting the CAN transmits at half the required speed.
To make it work on the bench I changed Register CxCTRL1 from 0x0800 to 0x0000
bit 11 = 0 //FCAN is equal to Fp, Datasheet page 362.

This works for my setup running at 1Mbit, not checked anything else as yet.
Regards, J.


kersing wrote:The controller on the ECIO 40P16 has a silicon issue which reverses that particular bit. May-be a property can be introduced to allow users to determine activation of a work-around. (Hard coding would work as long as Microchip does not release fixed silicon)

See errata for devices affected.

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Mon Aug 27, 2018 2:47 pm

I can confirm now this is the same problem as I have. But there is someone who can take the time to explain to me how I fix this

kennethnilsen69 wrote:I found this but do not know if it is the same.
But could anyone explain this a little better. What file and what should I change? I need to go Bus Rate 500


Jay Dee wrote:Hi,
Same as with FC6, Using standard setting the CAN transmits at half the required speed.
To make it work on the bench I changed Register CxCTRL1 from 0x0800 to 0x0000
bit 11 = 0 //FCAN is equal to Fp, Datasheet page 362.

This works for my setup running at 1Mbit, not checked anything else as yet.
Regards, J.


kersing wrote:The controller on the ECIO 40P16 has a silicon issue which reverses that particular bit. May-be a property can be introduced to allow users to determine activation of a work-around. (Hard coding would work as long as Microchip does not release fixed silicon)

See errata for devices affected.

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Tue Aug 28, 2018 8:50 am

another problem:
When I set component can1 (internal-1) bus rate to 1000 it works ok on bus rate 500.

but when i add can2 (internal-2) bus rate 1000, bus2 does not work properly. Yes it seems that it works at 500 rate but gives out the wrong data (I get ID 0 and DLC 0 and no data)

When I switch the TX and RX bus like this:

from:
CAN1:
TX Remap D0
RX Dmap B8
CAN2
TX Remap D6
RX Remap D7

To:
CAN1:
TX Remap D6
RX Remap D7
CAN2
TX Remap D0
RX Remap B8

Then everything turns and now CAN2 works, but not CAN1.

Any ideas?

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

Re: ECIO40P16 and Internal CAN truble

Postby Benj » Tue Aug 28, 2018 10:39 am

Hello,

I can confirm now this is the same problem as I have. But there is someone who can take the time to explain to me how I fix this


Just add this to your program inside a C icon after calling the CAN initialise macro.

Code: Select all

C1CTRL1 = 0x0000;
C2CTRL1 = 0x0000;


Not sure why D6 and D7 would be causing issues? I'll see if I can spot anything in the device datasheet.

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Tue Aug 28, 2018 11:53 am

Thank you benj the c command worked well :-)
Benj wrote:

Code: Select all

C1CTRL1 = 0x0000;
C2CTRL1 = 0x0000;



It's not D7 and D6 that's the problem. It is CAN component.
D7 and D6 work fine if I switch from CAN1 to CAN2 (Software only)

just me who writes and explains a little wrong. I try again


With this configuration, only CAN 1 works
CAN1: (internal-1)
TX Remap D0
RX Dmap B8
CAN2: (internal-2)
TX Remap D6
RX Remap D7

With this configuration, only CAN 1 works
CAN1: (internal-1)
TX Remap D6
RX Remap D7
CAN2 (internal-2)
TX Remap D0
RX Remap B8

component 2 does not work but the D7 and D6 work fine

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Tue Aug 28, 2018 11:59 am

More testing shows that it is Internal 2 that is not working.

If I only switch on Internal 1 and 2 from CAN1 and CAN2 then it's always internal 2 that does not work

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Thu Aug 30, 2018 1:18 pm

Hi Benj, have you had time to look at it?

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Thu Sep 06, 2018 2:27 pm

There is also another problem:
If I initialise CAN2, SetTxIdent and SetTxData do not work on CAN1

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

Re: ECIO40P16 and Internal CAN truble

Postby Benj » Thu Sep 06, 2018 3:09 pm

Hello,

Please can you confirm you are using FLowcode v7.3 and have applied the fixes from here.
viewtopic.php?f=63&t=19743#p86234

There are some CAN related fixes in there.

I'm just combing through the internal CAL code now to see if I can spot any problems.

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

Re: ECIO40P16 and Internal CAN truble

Postby Benj » Thu Sep 06, 2018 3:27 pm

Hello,

I believe I may have now fixed the problem. In the initialisation of the DMA the channel 2 pointers were referring to the channel 1 pins. Hopefully should all be resolved for you now.

Please copy the attached file into your "Flowcode 7/CAL/PIC16BIT" folder and let us know how you get on.

PIC16BIT_CAL_CAN.c
(70.65 KiB) Downloaded 58 times


The same problem exists in v8 so I'll get it fixed there too.

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Thu Sep 06, 2018 9:35 pm

Benj wrote:Hello,

Please can you confirm you are using FLowcode v7.3 and have applied the fixes from here.
viewtopic.php?f=63&t=19743#p86234

There are some CAN related fixes in there.

I'm just combing through the internal CAL code now to see if I can spot any problems.


Yes, I use Flowcode v7.3 with the fix :-) (v7.3.0.7)

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Thu Sep 06, 2018 9:58 pm

Benj wrote:Hello,

I believe I may have now fixed the problem. In the initialisation of the DMA the channel 2 pointers were referring to the channel 1 pins. Hopefully should all be resolved for you now.

Please copy the attached file into your "Flowcode 7/CAL/PIC16BIT" folder and let us know how you get on.

PIC16BIT_CAL_CAN.c

The same problem exists in v8 so I'll get it fixed there too.


This fixes the problem of the initialisation but still incorrect on CAN2
CAN1AndCAN2.JPG
CAN1AndCAN2.JPG (49.68 KiB) Viewed 2650 times


on first attempt after a power start, it sends out on CAN2 "ID 1 DLC 4 Data 04 00 04 00" instead of ID 100 DLC 8 Data 02 02 02 02 02 02 02 02

and after the first, it always sends out "ID 80 DLC 2 Remote Frame (DLC=2)" instead of ID 100 DLC 8 Data 02 02 02 02 02 02 02 02

ECIO40P16_CAN_BT_And_eeprom_Test.fcfx
(33.73 KiB) Downloaded 47 times

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Thu Sep 06, 2018 10:14 pm

And if I swap around Internal 1 and 2 i get this (only software swap)

CAN1AndCAN2 Internal1 and 2 Swap.JPG
CAN1AndCAN2 Internal1 and 2 Swap.JPG (44.5 KiB) Viewed 2649 times


ECIO40P16_CAN_BT_And_eeprom_Test.fcfx
(33.72 KiB) Downloaded 72 times

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

Re: ECIO40P16 and Internal CAN truble

Postby Benj » Fri Sep 07, 2018 10:07 am

Hello,

Many thanks for letting me know so fast. I've had another comb through and think I've found some more problems that have now been fixed. These have gotten rid of some compiler warnings so I am hopeful we are closer now.

Have a go and let us know how you get on.
PIC16BIT_CAL_CAN.c
(68.9 KiB) Downloaded 34 times

kennethnilsen69
Posts: 87
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: ECIO40P16 and Internal CAN truble

Postby kennethnilsen69 » Fri Sep 07, 2018 10:41 am

Sorry Benj but no difference with the latest update
These users thanked the author kennethnilsen69 for the post:
Benj (Fri Sep 07, 2018 11:53 am)
Rating: 5%
 

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

Re: ECIO40P16 and Internal CAN truble

Postby Benj » Fri Sep 07, 2018 4:06 pm

Thanks, I'll see if I can get it rigged up here to do a more thorough test for lurking CH2 bugs.