XMC1000 TIP of the day: External Oscillator Circuit using On-Chip Comparator

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
How you ever wonder how to use the analog comparator in XMC1200/XMC1300?
One of the application is use it as oscillator circuit.
The attached image show the 32.76kHz external oscillator circuit.
311.attach
The comparator in the circuit can be replace with the on-chip comparator by connecting (+) and (-) to the comparator input pin ACMPx.INP and ACMPx.INN and the output from the comparator will be from ACMPx.OUT.
For the schematic below, P2.9 is used as ACMP0.INP, P2.8 is used as ACMP0.INN and P0.10 is used as ACMP0.OUT.
312.attach

Then, by initialized the analog comparator and the port pin, a stable clock will be available at ACMP0.OUT.

void ACMP0_Init(void)
{
COMPARATOR->ANACMP0 = ((0x0 << COMPARATOR_ANACMP0_CMP_OUT_Pos) & COMPARATOR_ANACMP0_CMP_OUT_Msk) |
((0x0 << COMPARATOR_ANACMP0_CMP_LPWR_Pos) & COMPARATOR_ANACMP0_CMP_LPWR_Msk) |
((0x0 << COMPARATOR_ANACMP0_ACMP0_SEL_Pos) & COMPARATOR_ANACMP0_ACMP0_SEL_Msk) |
((0x0 << COMPARATOR_ANACMP0_CMP_HYST_ADJ_Pos) & COMPARATOR_ANACMP0_CMP_HYST_ADJ_Msk) |
((0x0 << COMPARATOR_ANACMP0_CMP_INV_OUT_Pos) & COMPARATOR_ANACMP0_CMP_INV_OUT_Msk) |
((0x1 << COMPARATOR_ANACMP0_CMP_FLT_OFF_Pos) & COMPARATOR_ANACMP0_CMP_FLT_OFF_Msk) |
((0x1 << COMPARATOR_ANACMP0_CMP_EN_Pos) & COMPARATOR_ANACMP0_CMP_EN_Msk) ;


}

void PORT_Init(void)
{
PORT0->IOCR8 = ((0x0 << PORT0_IOCR8_PC11_Pos) & PORT0_IOCR8_PC11_Msk) |
((0x14 << PORT0_IOCR8_PC10_Pos) & PORT0_IOCR8_PC10_Msk) |
((0x0 << PORT0_IOCR8_PC9_Pos) & PORT0_IOCR8_PC9_Msk) |
((0x0 << PORT0_IOCR8_PC8_Pos) & PORT0_IOCR8_PC8_Msk) ;

}
0 Likes
0 Replies