Hello,
I'm pretty new to this, so bear with me.
the following actions are from an example I have, and I'm trying to verify this against the datasheet, however I haven't found any resemblance .
I'm using mk10dn512M10 (this model does not appear in the catalog, which I'm having hard time finding any documentation for this model.
where I'm trying to use the CMP peripheral to compare between :
1. a pin on my MCU which connected to a battery
2. reference voltage from DAC
I configured the DAC to send output voltage on DAC output (3v) which is said to be connected to CMP1 input internally.
using this template:
// Configure the CMP1 input pin
// Assuming the pin is on Port C, adjust accordingly for other ports
PORTC_PCR[cmpInputPin] = PORT_PCR_MUX(7); // Set the pin as the CMP1 input
// Configure CMP1
CMP1_CR0 = CMP_CR0_FILTER_CNT(0x00); // Adjust filter count if needed
CMP1_CR1 = CMP_CR1_EN_MASK | CMP_CR1_OPE_MASK | CMP_CR1_PMODE_MASK; // Enable the comparator, set high-speed mode
CMP1_MUXCR = (CMP1_MUXCR & ~CMP_MUXCR_PSEL_MASK) | CMP_MUXCR_PSEL(cmpInputPin); // Set the CMP1 positive input to the specified pin
I tried to read the CMP with :
if (CMP1_SCR & CMP_SCR_COUT_MASK)
but I don't seem to have any change occuring at the CMP COUT.
I would appreciate help in understanding what is a general flow of the CMP peripheral as well.
thank you.