1.3.3.46 1.9.3.46 1.10.3.3 1.11.3.2 1.12.3.2 1.18.2.3 1.21.2.3 1.22.3.3 1.23.3.3 1.24.3.3 1.24.4.2 1.25.3.10 1.29.3.46 1.32.3.46 CANx_BitTimingCalculationGet Function

C

bool CANx_BitTimingCalculationGet(CAN_BIT_TIMING_SETUP *setup, CAN_BIT_TIMING *bitTiming);

Summary

Calculate the CAN bit timing parameters which will be used to configure the CAN bit timing using CANx_BitTimingSet() API.

Description

This function is used to calculate the CAN bit timing parameters at run time based on the parameter are specified via the CAN_BIT_TIMING_SETUP type parameter. This function returns the calculated CAN bit timing parameters in the CAN_BIT_TIMING type parameter.

Precondition

None.

Parameters

Param Description
setup defines parameters required for bit timing calculations
bitTiming CAN bit timing parameters structure

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

None.