Macros | |
#define | CS_DCO_FREQ 16384000 |
Functions | |
void | CS_setupDCO (uint8_t mode) |
Sets up the DCO using the selected mode. More... | |
void | CS_initClockSignal (uint8_t clockSource, uint8_t clockSourceDivider) |
Initializes a clock singal with a divider. More... | |
uint32_t | CS_getACLK (void) |
Get the current ACLK frequency in Hz. More... | |
uint32_t | CS_getSMCLK (void) |
Get the current SMCLK frequency in Hz. More... | |
uint32_t | CS_getMCLK (void) |
Get the current MCLK frequency in Hz. More... | |
uint8_t | CS_getFaultFlagStatus (uint8_t mask) |
Get the DCO fault flag status. More... | |
uint32_t CS_getACLK | ( | void | ) |
Get the current ACLK frequency in Hz.
This API returns the current ACLK frequency in Hz. It does not work when the device is setup in DCO bypass mode. Also, CS_setupDCO() should be called before this API so that the DCO has been calibrated and this calculation is accurate.
uint8_t CS_getFaultFlagStatus | ( | uint8_t | mask | ) |
Get the DCO fault flag status.
Reads and returns DCO fault flag. The DCO fault flag is set when the DCO is operating in external resistor mode and the DCO detects an abnormality. An abnormality could be if the ROSC pin is left open or shorted to ground, or if the resistance connected at the ROSC pin is far away from the recommended value. If the fault persists the DCO automatically switches to the internal resistor mode as a fail-safe mechanism.
mask | Mask of fault flags to check Mask value is the logical OR of any of the following:
|
uint32_t CS_getMCLK | ( | void | ) |
Get the current MCLK frequency in Hz.
This API returns the current MCLK frequency in Hz. It does not work when the device is setup in DCO bypass mode. Also, CS_setupDCO() should be called before this API so that the DCO has been calibrated and this calculation is accurate.
uint32_t CS_getSMCLK | ( | void | ) |
Get the current SMCLK frequency in Hz.
This API returns the current SMCLK frequency in Hz. It does not work when the device is setup in DCO bypass mode. Also, CS_setupDCO() should be called before this API so that the DCO has been calibrated and this calculation is accurate.
void CS_initClockSignal | ( | uint8_t | clockSource, |
uint8_t | clockSourceDivider | ||
) |
Initializes a clock singal with a divider.
Sets up a clock signal with a divider. If the DCO is in bypass mode the frequency will be CLKIN / divider. If the DCO is not in bypass mode the frequency will 16.384MHz / divider.
clockSource | Clock signal to initialize Valid values are:
|
clockSourceDivider | Divider setting for the selected clock signal Valid values are:
|
void CS_setupDCO | ( | uint8_t | mode | ) |
Sets up the DCO using the selected mode.
Sets up the DCO using the selected mode. If the bypass mode is selected than an external digital clock is required on the CLKIN pin to drive all clocks on the device. ACLK frequency is not programmable and is fixed to the bypass clock frequency divided by 512. For external resistor mode a 20kOhm resistor is recommended at the ROSC pin. External resistor mode offers higer clock accuracy in terms of absolute tolerance and temperature drift compared to the internal resistor mode. Please check your device datasheet for details and ratings for the differnt modes.
mode | Mode to put the DCO into Valid values are:
|