Change of Can FD timing

Universal Programmable Converter for CAN FD and CAN
Post Reply
JayHLim
Posts: 5
Joined: Sun 18. Aug 2024, 04:53

Change of Can FD timing

Post by JayHLim » Tue 5. Nov 2024, 06:57

Hello,

I need your advice for my application using PCAN-Router FD.
1. CAN2 is fixed setting as CAN 500K (#define _80M_500K_80____2M_80_ISO_NEW { CAN_CLOCK_80M, 4, 31, 8, 8, 96, 0, 1, 4, 7, 2, 2})
2. CAN1 is two kind of setting as CAN-FD (1) #define _80M_500K_80____2M_80_ISO_CANFD {CAN_CLOCK_80M, 2, 63, 16, 15, 96, 0, 1, 2, 15, 4, 4}
(2) #define _80M_500K_70____2M_75_ISO { CAN_CLOCK_80M, 2, 55, 24, 2, 96, 0, 1, 2, 14, 5, 5}

My intention is that change CAN1 setting as (1) or (2) via CAN2 message by another device.
If I send message of ID 0x771 via CAN2, CAN1 change to setting as (1).
If I send message of ID 0x772 via CAN2, CAN1 change to setting as (2).

I cannot sure it is possible or Not. Can you advice to me?

Thanks,

M.Maidhof
Support
Support
Posts: 1751
Joined: Wed 22. Sep 2010, 14:00

Re: Change of Can FD timing

Post by M.Maidhof » Tue 5. Nov 2024, 11:49

Hi,

yes, this is possible. You can change the CAN initialization during normal operation by calling:

CAN_UnInitialize ( CANHandle_t hBus);

followed by

CAN_Initialize ( CANHandle_t hBus, const CANTiming_t *timing);

with the new settings for your CAN channel. Please see \inc\can.h for more details about the API for the PCAN-Router FD

regards

Michael

JayHLim
Posts: 5
Joined: Sun 18. Aug 2024, 04:53

Re: Change of Can FD timing

Post by JayHLim » Sat 7. Dec 2024, 06:48

Hello,

I would ask more one question.
CAN1 can be Initialized as Variables Not Const? I want change CAN timing parameters by external command via CAN2.

- CAN_Initialize ( CANHandle_t hBus, const CANTiming_t *timing); --> CAN_Initialize ( CANHandle_t hBus, CANTiming_t *timing); ??

if it is possible, pls let me know the solution.

M.Maidhof
Support
Support
Posts: 1751
Joined: Wed 22. Sep 2010, 14:00

Re: Change of Can FD timing

Post by M.Maidhof » Mon 9. Dec 2024, 12:34

Hi,

yes, also possible. Your variable must be of type CANTiming_t than:

Code: Select all

typedef struct {

uint32_t  can_clk;				//!< clock for CAN controller, see CAN_CLOCK_...

uint16_t  nom_brp;				//!< prescaler for arbitration phase ( 1..1024)
uint16_t  nom_tseg1;				//!< Tseg1 for arbitration phase ( 1..256)
uint8_t   nom_tseg2;				//!< Tseg2 for arbitration phase ( 1..128)
uint8_t   nom_sjw;				//!< SJW for arbitration phase ( 1..128)

uint8_t   warning_limit;		//!< error warning limit ( ewl typical 96)
uint8_t   listen_only;			//!< 0=normal, 1=listen only mode
uint8_t   can_mode;				//!< 0=CAN-FD nonISO, 1=CAN-FD ISO, 2=CAN_20_AB (forced)

uint16_t  data_brp;				//!< prescaler for CAN-FD data phase ( 1..1024)
uint8_t   data_tseg1;			//!< Tseg1 for CAN-FD data phase ( 1..32)
uint8_t   data_tseg2;			//!< Tseg2 for CAN-FD data phase ( 1..16)
uint8_t   data_sjw;				//!< SJW for CAN-FD data phase ( 1..16)

} CANTiming_t;
regards

Michael

Post Reply