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
CANBUS with 8MHz
Moderator: Benj
-
- Posts: 21
- Joined: Wed Jun 19, 2013 8:43 am
- Has thanked: 2 times
- Been thanked: 3 times
- Contact:
- 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
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?
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?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 21
- Joined: Wed Jun 19, 2013 8:43 am
- Has thanked: 2 times
- Been thanked: 3 times
- Contact:
Re: CANBUS with 8MHz
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?
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?
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 21
- Joined: Wed Jun 19, 2013 8:43 am
- Has thanked: 2 times
- Been thanked: 3 times
- Contact:
Re: CANBUS with 8MHz
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.
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.
- QMESAR
- 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
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 elseWolfgang 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);
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 (81.56 KiB) Viewed 5863 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 21
- Joined: Wed Jun 19, 2013 8:43 am
- Has thanked: 2 times
- Been thanked: 3 times
- Contact:
Re: CANBUS with 8MHz
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
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
- 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
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.
The files will need to be placed here before starting Flowcode: "C:\Program Files (x86)\Flowcode 6\components"
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.
The files will need to be placed here before starting Flowcode: "C:\Program Files (x86)\Flowcode 6\components"
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 21
- Joined: Wed Jun 19, 2013 8:43 am
- Has thanked: 2 times
- Been thanked: 3 times
- Contact: