internal can problem for18f258

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
misoct
Posts: 64
Joined: Sat Sep 04, 2010 11:03 pm
Location: Egypt
Has thanked: 8 times
Been thanked: 17 times
Contact:

internal can problem for18f258

Post by misoct »

Dear All
I constructed a can project using intrnal can chip 18f258 and I tested by VNET ,the project is working fine but when I compile to the hardware(2-multiprorammer+sensisor board+lcd e block) there is no comminication between the collector and display
can anyone help me to review the configuration where I am using V4.5 and I install the updatin files related to can
thanks
Image
Attachments
CAN_Example_04_Send.fcf
(9.5 KiB) Downloaded 410 times
CAN_Example_04_Receive.fcf
(21.02 KiB) Downloaded 394 times

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

Re: internal can problem for18f258

Post by Benj »

Hello Misoct,

Looking at the code Flowcode is generating it is using the CAN on the SPI interface by default?

If you find this line in your C file generated by Flowcode then you can confirm this.
#define INTERNAL_CAN_ENABLE 0
You will need to select the CAN component on the panel and then use the custom code feature to edit the defines section of code.

Find the line

Code: Select all

#define INTERNAL_CAN_ENABLE		%b
and change to

Code: Select all

#define INTERNAL_CAN_ENABLE		1
Let me know how you get on.

User avatar
misoct
Posts: 64
Joined: Sat Sep 04, 2010 11:03 pm
Location: Egypt
Has thanked: 8 times
Been thanked: 17 times
Contact:

Re: internal can problem for18f258

Post by misoct »

Hi Ben
Thank you for quick reply,I have changed the line code as you sent me in both two program but the problem still as it is can you advise me more how to solve the problem
thanks

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

Re: internal can problem for18f258

Post by Benj »

Hello,

I see in your transmitter program you are using a clock speed of 19.6608MHz and in the receiver you are using 20MHz. However in your schematic you are using 8MHz crystals. Could this be the cause of the problem?

User avatar
misoct
Posts: 64
Joined: Sat Sep 04, 2010 11:03 pm
Location: Egypt
Has thanked: 8 times
Been thanked: 17 times
Contact:

Re: internal can problem for18f258

Post by misoct »

Hello Ben
I used the crystal imbedded in the two multiprogrmmers E- bloks which 19.6608 and the crystal in the is schematic for representation only
However I have changed the crystal in the program from 20 MHz to 19.6608 and there is no change the problem still as it is
Can you share me about that the cause of the problem may be:
1-I changed the two programs chip from 16f877A to 18f258 without any change in the building of the flowcod configuration
2-I made a unification between the power supply of the two kits
3- the difference between the brand of each of mutiprogrammer where I am using old one and the other is updated
thanks

User avatar
misoct
Posts: 64
Joined: Sat Sep 04, 2010 11:03 pm
Location: Egypt
Has thanked: 8 times
Been thanked: 17 times
Contact:

Re: internal can problem for18f258

Post by misoct »

Hi,
I have tested my hardware with another program ,and the hardware is working fine now with following configuration
CAN speed parameters are:
Microcontroller clock: 8MHz
CAN Bus bit rate: 100Kb/s
Sync_Seg: 1
Prop_Seg: 6
Phase_Seg1: 6
Phase_Seg2: 7
SJW: 1
BRP: 1
Sample point: 65%
can any one help me to reconize the difference , so I want to use flowcode
thanks
Attachments
DISPLAY.c
(4.14 KiB) Downloaded 379 times
COLLECTOR.c
(3.76 KiB) Downloaded 375 times

User avatar
Steve
Matrix Staff
Posts: 3421
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: internal can problem for18f258

Post by Steve »

Please post your latest programs so we can see the latest settings. Also, have you created a simple flasher program in Flowcode to ensure your clock speed and other config settings are correct?

User avatar
misoct
Posts: 64
Joined: Sat Sep 04, 2010 11:03 pm
Location: Egypt
Has thanked: 8 times
Been thanked: 17 times
Contact:

Re: internal can problem for18f258

Post by misoct »

Hello
Ihave checked the oscillation by inserting led blanking and I am sure that all right
thanks
Attachments
CAN_Example_04_Receive.fcf
(47 KiB) Downloaded 380 times
CAN_Example_04_Send.fcf
(36.41 KiB) Downloaded 369 times

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

Re: internal can problem for18f258

Post by Benj »

Hello,

I think the internal CAN component will work with any clock speed but would it be possible to test using a 20MHz crystal. You would have to update your project options and CAN component properties to match. I am just suggesting this because the original code we used to create the internal CAN component was designed for 20MHz only and it might help to pinpoint a problem.

I also have a test rig for the internal CAN and this works at 20MHz so maybe my test rig is missing a trick.

Other then that I'm not sure. Your schematic seems to check out so I don't think its this. Have you done continuity tests on your hardware to make sure the wiring and soldering is all ok?

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

Re: internal can problem for18f258

Post by Benj »

Hello,

Right I have managed to find a bit of time to look into this issue, sorry for the delay. I currently am unable to send or receive using the internal CAN in v4 on my hardware. The strange thing is that I know this was working so i'm a little unsure as to what's gone wrong. I think I will compare my current Flowcode v4.5 code with the code i'm using at home and see if I can spot any differences. I will be in touch as to what I discover.

Here is the C file from my local v4.5 install.
Attachments
CAN_Example_04_Receive.c
(65.99 KiB) Downloaded 371 times

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

Re: internal can problem for18f258

Post by Benj »

Hello,

Right the C files match so I am going to try some further tests to see what is going wrong here. I know this was working great with the existing MIAC and E-block CAN routines but you never know something might have got mixed up and the baud or something similar may no longer be correct. I should have a CAN analyser around somewhere so I will let you know how i'm getting on.

Hmmm...

User avatar
misoct
Posts: 64
Joined: Sat Sep 04, 2010 11:03 pm
Location: Egypt
Has thanked: 8 times
Been thanked: 17 times
Contact:

Re: internal can problem for18f258

Post by misoct »

Hello
In any case thank you for your interest and I hope that up to solve the problem as soon as possible ,because I have noted since a long time ,and if the issue is resolvedit will increase the strength and credibility of Flowcode
Thanks
Tharowat

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

Re: internal can problem for18f258

Post by Benj »

Hello Tharowat,

I have been looking into this and cannot see the reason for the code not to be working. As I say I have compared it with known working code and it is identical. I have a system setup on my desk linked to a can analyser and the analyser is currently only showing the data produced by the MIAC. Hopefully I can get to the bottom of this for you. I will have another crack at it this afternoon so will let you know how I get on.

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

Re: internal can problem for18f258

Post by Benj »

Hello,

Right there is data going out from the internal CAN component but something is obviously not right.

Here is a trace from the MIAC.
valid_MIAC.JPG
valid_MIAC.JPG (13.7 KiB) Viewed 11954 times
And here is a trace from the internal CAN
Invalid_internal.JPG
Invalid_internal.JPG (12.3 KiB) Viewed 11954 times
Hmm....

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

Re: internal can problem for18f258

Post by Benj »

Just so you know, I'm having another dig into this tonight so hopefully I can come up with something to fix the problem.

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

Re: internal can problem for18f258

Post by Benj »

Seeing as the problem doesn't seem to be the code and the baud settings are correct I wonder if the issue could be compiler related? I seem to remember this was updated for v4.5. I will have a go with the HiTech compiler and let you know how I get on.

Post Reply