Hi,
I am using development board TWR-KM34Z75M and I have found a problem about Vref stabilization flag.
The VREFST flag is supposed to be set when the signal is stable, but this is not whap happens.
From the moment I enable the Vref module (VREFEN = 1) the VREFST flag is istantaneously set to 1!
I didn't find a way to clear it, so how to set up correctly the Vref module in order to see this flag working?
It's very important for me to check when the Vref is stable, so why this flag doesn't work correctly?
This is the code about the Vref configuration.
void BOARD_VREF_Config(void)
{
vref_config_t config;
/*
* config.bufferMode = kVREF_ModeHighPowerBuffer;
* config.bufferMode = kVREF_ModeTightRegulationBuffer;
* config.enableExternalVoltRef = false;
* config.enableLowRef = false;
*/
/* Get vref default config. */
VREF_GetDefaultConfig(&config);
/* Enable low reference volt (VREF_L) */
config.enableLowRef = true;
/*Enable low power mode*/
config.bufferMode = kVREF_ModeHighPowerBuffer;
/* Init vref */
VREF_Init(VREF, &config);
/* Vref set low trim reference (VREF_L) */
VREF_SetLowReferenceTrimVal(VREF, 3U);
/* Vref set trim, this value will not be the same with every boards */
VREF_SetTrimVal(VREF, 46U);
}
All these functions and structs are taken from nxp libraries.
Try to debug step by step the VREF_Init function and you will see the problem when you'll reach this line:
/* Enable VREF module */
reg |= VREF_SC_VREFEN(1U);
/* Update bit-field from value to Status and Control register */
base->VREFH_SC = reg;
Best regards.
Hi,
I would recommend customer to download the latest MCUXpresso SDK VERF driver for TWR-KM34Z75M board from here.
I had tested the VREF driver with below code, which works as expected.
#include "fsl_vref.h"
vref_config_t vrefUserConfig;
VREF_GetDefaultConfig(&vrefUserConfig); /* Gets a default configuration. */
vrefUserConfig.bufferMode = kVREF_ModeLowPowerBuffer;
VREF_Init(VREF, &vrefUserConfig); /* Initializes and configures the VREF module */
Wish it helps.
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
the code I used is the latest from MCUXpresso SDK.
So you say it's working... how much time passes from the moment you enable Vref to the moment the VREFST flag is set? 1us? 100us? 20ms? 40ms?
Regards.
Hello Matteo,
The VREF module section in the KM34 Reference Manual states that after SC[VREFEN] is set to 1, wait for 40 ms for startup and stabilization. This is a generalization but the actual spec below is given as the official specification.
The KM34 Data Sheet has a specification for the Buffer Startup time of 20 ms.
here are links to the documents I'm referring to.
Name/Description | Modified Date |
---|---|
It is very likely that a call within the SDK to read back the status register would immediately read true indicating the module was stable. The SDK code is not compact and the code could easily be taking hundreds of cpu cycles to accomplish the write and subsequent read.
If you do not want to trust the status bit then I suggest you wait the prescribed period of time before using the VREF module output.
Best Regards,
Philip Drake