I have a custom board with an MK20DX256VLK10. We are trying to use a single-ended line on ADC0 to measure a voltage with respect to the VREF_OUT pin. We want to use the mode where VREF_OUT is a 1.2V output from the K20.
My issue is that the VREF_SCVREFST_MASK bit never goes HIGH in the VREF_SC register.
I use the following MQX code to try to initialize the VREF module. I've confirmed the VREFST bit is LOW from the CodeWarrior debugger. The VREF_OUT pin on the K20 has a 100 nF capacity between it and GND as required by the Reference Manual. I've tried cranking out the delay loop to 500 ms, but I still get the same result.
Please help. Am I doing something incorrect here?
boolean EnableVRefAlt (void)
boolean returnValue; // Return value from this function.
const int32_t VOLTAGE_STABLE_MS = 10; // Milliseconds to wait for the VREF_OUT voltage to
// Make sure the clock is turned on to the K20 VREF module.
SIM_SCGC4 |= SIM_SCGC4_VREF_MASK;
VREF_SC = VREF_SC_VREFEN_MASK;
returnValue = FALSE;
// Wait for the voltage to stabilize.
for (iReturn = 0; iReturn < VOLTAGE_STABLE_MS; ++iReturn)
if (VREF_SC_VREFST_MASK == (VREF_SC & VREF_SC_VREFST_MASK))
returnValue = TRUE;
if (! returnValue)
printf("After %d ms, VREF voltage is not stable, VREF_SC = 0x%X.\n", iReturn, VREF_SC);