CANBUS with 8MHz

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

Moderator: Benj

Post Reply
Wolfgang Kos
Posts: 21
Joined: Wed Jun 19, 2013 8:43 am
Has thanked: 2 times
Been thanked: 3 times
Contact:

CANBUS with 8MHz

Post by Wolfgang Kos »

Hello,

I am testing the Demo file CAN_Demo.fcfx, it will function good (20MHz).
Now i will testing with 8MHz and changed the speed under Options.
It will not function.

What can I make.

Thank you for all tipps.

Wolfgang

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: CANBUS with 8MHz

Post by Benj »

Hello,

Have you done a 1 second flasher test to ensure your hardware is running at the speed you think it is.

http://www.matrixtsl.com/wiki/index.php ... ED_flasher

How are you driving the CAN? is it internal or external to your target micro?

Wolfgang Kos
Posts: 21
Joined: Wed Jun 19, 2013 8:43 am
Has thanked: 2 times
Been thanked: 3 times
Contact:

Re: CANBUS with 8MHz

Post by Wolfgang Kos »

Hello Benj,

yes the flasher will function, the CAN is internal it will function with chrystal 20MHz.
I changed the chrystal in 8MHz and changed the Speed it will not function.
Do I Change the code manually in flowcode for the Speed, why the Speed with 20MHz is in the Code from Flowcode fixed or have you a good info?

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: CANBUS with 8MHz

Post by Benj »

Hello,

Have you changed the clock speed setting in the project options?

Also please can you post your program and I will have a look for you to see if there is anything obvious.

Wolfgang Kos
Posts: 21
Joined: Wed Jun 19, 2013 8:43 am
Has thanked: 2 times
Been thanked: 3 times
Contact:

Re: CANBUS with 8MHz

Post by Wolfgang Kos »

Hello,

yes I changed the clock Speed under Options.
I look in the C-Code the CNF and control Register will not changed automatic when I swicht from 20Mhz.to 8MHz.

//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, 3);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_CNF2, 209);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_CNF3, 3);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_TXRTSCTRL, 0);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_EFLG, 0);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_CANCTRL, 0x80);
FC_CAN_SPI_CAN_Config_1(FCV_0e701_can1__CAN_REQOP_NORMAL);

Now i will ckeck a other CNF Code...
________________________________________________________________________________________________

This is the Online Demo Code I changed the processor and set the button = 1 for testing and make a Counter for Zahl, 20MHz it will good function.
Koernersensor_20MHz.fcfx
20MHz
(17.89 KiB) Downloaded 216 times
Koernersensor_8MHz_.fcfx
8MHz
(17.89 KiB) Downloaded 206 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: CANBUS with 8MHz

Post by QMESAR »

Wolfgang Kos wrote://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, 3);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_CNF2, 209);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_CNF3, 3);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_TXRTSCTRL, 0);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_EFLG, 0);
FC_CAN_SPI_CAN_Write_1(FCV_0e701_can1__CAN_CANCTRL, 0x80);
FC_CAN_SPI_CAN_Config_1(FCV_0e701_can1__CAN_REQOP_NORMAL);
This will not change if you change the Oscillator frequency ,it is the CAN baud rate registers that will only change if you change baud rate from 250Kb/sec to something else

In your setup you use 8Mhz Oscillator and HS setting which is for Crystals bigger then 10Mhz I would advise you to set it to XT not HS ,I suspect you controller is not running or not correctly
Attachments
13.05.jpg
13.05.jpg (81.56 KiB) Viewed 5864 times

Wolfgang Kos
Posts: 21
Joined: Wed Jun 19, 2013 8:43 am
Has thanked: 2 times
Been thanked: 3 times
Contact:

Re: CANBUS with 8MHz

Post by Wolfgang Kos »

Hello I solved the Problem :-)

I changed manualy the register Code in asm like this for 8Mhz.

MOVLW 0x05
MOVWF gbl_brgcon3
MOVLW 0xB8
MOVWF gbl_brgcon2
MOVLW 0x00
MOVWF gbl_brgcon1
MOVLB 0x0F
__________________________________________
old register Code:
MOVLW 0x03
MOVWF gbl_brgcon3
MOVLW 0xD1
MOVWF gbl_brgcon2
MOVLW 0x01
MOVWF gbl_brgcon1


This Code will not changed automatic when the clock will changed, is always the same.

I think this is a bug, can fix it or a indication that this is only for 20Mhz. CAN-Bus

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: CANBUS with 8MHz

Post by Benj »

Hello,

Thanks for letting me know how you got around the problem. I have had a look at the code and the clock speed is taken into account but only when you add the component onto your panel. Therefore changing the clock speed in a project that already had the CAN component did not work to change the baud values.

I have now fixed this so the clock speed calculation is redone whenever you compile which should hopefully solve the problem.
CAN.fcpx
(22.48 KiB) Downloaded 207 times
cal_can.fcpx
(10.14 KiB) Downloaded 224 times
The files will need to be placed here before starting Flowcode: "C:\Program Files (x86)\Flowcode 6\components"

Wolfgang Kos
Posts: 21
Joined: Wed Jun 19, 2013 8:43 am
Has thanked: 2 times
Been thanked: 3 times
Contact:

Re: CANBUS with 8MHz

Post by Wolfgang Kos »

Hello,

thank you very much... i will testing

Post Reply