1.3.3.47 1.9.3.47 1.10.3.2 1.11.3.3 1.12.3.3 1.18.2.2 1.21.2.2 1.22.3.2 1.23.3.2 1.24.3.2 1.24.4.3 1.25.3.11 1.29.3.47 1.32.3.47 CANx_BitTimingSet Function
C
bool CANx_BitTimingSet(CAN_BIT_TIMING *bitTiming);
Summary
Configure the CAN bit timing at run time.
Description
This function allows the application to change the CAN bit timing parameters at run time. The application can thus override the MCC defined configuration for these parameters. The parameter are specified via the CAN_BIT_TIMING type parameter. Each member of this parameter should be initialized to the desired value.
Precondition
None.
Parameters
Param | Description |
---|---|
bitTiming | bit timing parameters |
Returns
status of the request
true : request successful
false : request failed
Example
volatile bool status = false; CAN_BIT_TIMING_SETUP setup = {0}; CAN_BIT_TIMING bitTiming = {0}; setup.nominalBitTimingSet = true; setup.nominalBitRate = 250000; setup.nominalPrescaler = 0; setup.nominalSamplePoint = 75; setup.dataBitTimingSet = true; setup.dataBitRate = 1000000; setup.dataPrescaler = 3; setup.dataSamplePoint = 75; status = CAN1_BitTimingCalculationGet(&setup, &bitTiming); if (status) { status = CAN1_BitTimingSet(&bitTiming); } –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-- volatile bool status = false; CAN_BIT_TIMING_SETUP setup = {0}; CAN_BIT_TIMING bitTiming = {0}; setup.nominalBitTimingSet = true; setup.nominalBitRate = 500000; setup.nominalPrescaler = 7; setup.nominalSamplePoint = 75; setup.nominalPropagTime = 300; status = CAN1_BitTimingCalculationGet(&setup, &bitTiming); if (status) { status = CAN1_BitTimingSet(&bitTiming); }
Remarks
Calling this function will affect any ongoing communication. The application must thus ensure that there is no on-going communication on the CAN before calling this function.