Tuning the voltage reference of k64f?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tuning the voltage reference of k64f?

1,268 Views
runarhaaskjold
Contributor II

Hello guys.

I have a question regarding the voltage reference of the K64F. Cause some problem with INA250 (and limited time), I have to get an output of maximum 100mV from the DAC. Haven't tested it with a filter, to remove noise. Is it realistic?

Second question is, could I tune the voltage reference so that i get more than 100 steps? (100mV is about 100 steps with 3.3V reference). I read through the reference manual, but with lack of sucess.

kDacRefVoltSrcOfVref 1 or 2 is something I can use?

I know the K64F originally has a vref of 1.2V, how can i use this instead of the 3.3V?

Regards

Runar Haaskjold

0 Kudos
Reply
5 Replies

970 Views
runarhaaskjold
Contributor II

Hey, Jorge. Thanks for responding.

I used the dac example of SKD1.3 and inputted the extra line of code inbetween struct and init.
I tested using an oscilloskop, and setting kDacRefVoltSrcOfVref1 gives no outputvoltage of the DAC.

I first though that maybe the function was wrong, but setting kDacRefVoltSrcOfVref2 works as it should. Am I missing something. Too use the other voltage reference do i have to do something analog? Im kinda stuck with this one. I will try at it at SDK2.0 and see if it works there!

If you got any more information, Id appricate that. If not, thanks for helping me!

Best regards

Runar Haaskjold

0 Kudos
Reply

970 Views
runarhaaskjold
Contributor II

I see that I was in a hurry, and my formulation  was not ideal.

I want to get a maximum of 100mV out from the DAC, and therefore need as many steps as possible between 0 - 100 mV. I’m limited to do this with a circuit, so I want to change the Vref (from 3.3 to 1.2) and thus get a better resolution.
  After some research, I’ve conclued that I’I need to activate DACREF_1.

So I have two options:

  • I can either write to its base address (400CC023) and right shift 1 into the different register (DACRFS and others) though I have very limited knowledge on how to do so. 

  • Or I can set kDacRefVoltSrsOfVref1 somewhere, (in a c-file or header), but I can’t find where it’s defined..?

Anyone got any input advice?

Thanks for reading!

Runar

0 Kudos
Reply

970 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Runar Haaskjol

What IDE are you using? You are using an example code?

Yes, as you said you have two option;

You can select the DACREF_1, in the DACRFS field from the DACx_C0 control register, in the KDS IDE this can be done by:  DAC0_C0 |= DAC_C0_DACRFS_MASK;

Or, in case you are using kinetis KSDK, in the main of the dac_example_frdmk64f you will find:

// Fill the structure with configuration of software trigger.

DAC_DRV_StructInitUserConfigNormal(&dacUserConfig);

// Initialize the DAC Converter.

DAC_DRV_Init(DAC_INSTANCE, &dacUserConfig);

Where

dac_status_t DAC_DRV_StructInitUserConfigNormal(dac_converter_config_t *userConfigPtr)

{

if (!userConfigPtr)

{

return kStatus_DAC_InvalidArgument;

}

userConfigPtr->dacRefVoltSrc = kDacRefVoltSrcOfVref2; /* Vdda */

userConfigPtr->lowPowerEnable = false;

return kStatus_DAC_Success;

}

When you can see that the refVolt is selected. You can copy this code and put it in your project

Hope this information helps

Regards

Jorge Alcala

0 Kudos
Reply

970 Views
runarhaaskjold
Contributor II

Hey Jorge, sorry for my late respond, things have been hectic. I'm using Keil IDE (uvision), and using example code from KDSK 1.3. I located the function you named in the "fsl_dac_driver", but changing it just prevented me from using the DAC. I went on searching for other ways of changing it, and stumbled over this code:

-------------------------------------------------------------------------------------------------------------------------------------

void DAC_HAL_ConfigConverter(DAC_Type * base, const dac_converter_config_t *configPtr)

{

    uint8_t c0;

  

    c0 = DAC_RD_C0(base);

    c0 &= ~(  DAC_C0_DACRFS_MASK

            | DAC_C0_LPEN_MASK  );

    if (kDacRefVoltSrcOfVref2 == configPtr->dacRefVoltSrc)

    {

        c0 = DAC_C0_DACRFS_MASK;

    }

    if (configPtr->lowPowerEnable)

    {

        c0 |= DAC_C0_LPEN_MASK;

    }

  

    DAC_WR_C0(base, c0);

}

-------------------------------------------------------------------------------------------------------------------------------------

I dont fully understand the code, but changing something here may help me?
Reading from the datasheet K64F:

0  selects DACREF_1 as the reference voltage.

1  selects DACREF_2 as the reference voltage.

The register is DACRFS in C0.

Got any more suggestions?

Regards

Runar Haaskjold

0 Kudos
Reply

970 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Runar Haaskjol

You don't need to change the driver code, the dacUserConfig is a structure that define the reference voltage and the low power mode, in the example code from KSDK this set it up in a "normal mode", so in main.c, the source reference voltage is defined as kDacRefVoltSrcOfVref2 with the instruction DAC_DRV_StructInitUserConfigNormal(&dacUserConfig);  but you can reconfigure this structure before initialize the dac.

   

  // Fill the structure with configuration of software trigger.

DAC_DRV_StructInitUserConfigNormal(&dacUserConfig);

    // Here: the dacRefVoltSrc is Redefined as kDacRefVoltSrcOfVref1

dacUserConfig.dacRefVoltsrc=kDacRefVoltSrcOfVref1;

    // Initialize the DAC Converter.

DAC_DRV_Init(DAC_INSTANCE, &dacUserConfig);

 

The code above show you how configure your dacUserConfig, please note that this has to be done after fill the structure and before you initialize the DAC.

Alternatively, you can configure you structure any time in your code if you change the dacUserConfig and then use the HAL function that you mentioned. Something like

dacUserConfig.dacRefVoltsrc=kDacRefVoltSrcOfVref1;

DAC_HAL_ConfigConverter(DAC_INSTANCE, &dacUserConfig);

Hope this information can help you.

Jorge Alcala

0 Kudos
Reply