DAC not working on FRDM-K22F

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

DAC not working on FRDM-K22F

Jump to solution
1,599 Views
vishalgirisagar
Contributor II

Hi All,

   I am using KDS IDE and K22F Kinetis board. I want to implement simple Digital - Analog converter. I am trying using Processor Expert. The configuration done is as shown below.

 

I add "DAC_LDD" component. Since the MCU supports only 1 DAC, i.e "DAC0_OUT/CMP1_IN3/ADC0_SE23".

I use 12 bit resolution as it supports 12-bit.

No interrupts.

No hardware buffer

No DMA

Enable in init code

Autoinitialisation.

 

In main loop, I call

  for (;;) {

   Error = DA1_SetValue(NULL, 4095U);                    /* Set converter output */

  }

 

Value of Error is 0 which mean setting value was successful. I also see all the registers are set properly. I try to measure value on the DAC_output pin using multimeter. I expect the value to be 3.3V. But I am getting few milli volts which means DAC is not working properly. Can some one please tell me if I am missing something. Thanks a lot in advance.

 

Also, why would one use DMA with DAC? Using DMA with ADC makes sense. But why with DAC?

 

47313_47313.pngpastedImage_1.png

 

Message was edited by: Vishal Girisagar

Labels (1)
Tags (3)
1 Solution
961 Views
DavidS
NXP Employee
NXP Employee

Hi Vishal,

Please set the voltage reference in the DAC component to "external" from "internal".

I also added in a delay loop (polling) so it doesn't change too fast as I used a Voltmeter to watch the DAC output.

Regards,

David

View solution in original post

0 Kudos
9 Replies
961 Views
DavidS
NXP Employee
NXP Employee

Hi Vishal,

I haven't had time to dig deeper but first impression is maybe the PORT clock is not enabled, and the PCR register MUX not programmed.

Regards,

David

0 Kudos
961 Views
vishalgirisagar
Contributor II

Hi David,

   There is no need to configure PCR register MUX because DAC is default function on this pin. I have attached a pic from data sheet below.

Also Port clock is enabled in the componenet section. Screenshot attached below.

pastedImage_0.png

pastedImage_1.png

0 Kudos
961 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Vishal,

I recommend you refer to the "Typical Usage" of DAC component , there are some demo how to configure the DAC and sample project .

Hope it can help you !

Alice

0 Kudos
961 Views
vishalgirisagar
Contributor II

Hi Alice,

   Can you please point me to those? That will be of great help.

0 Kudos
961 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi  Vishal ,

here :

pastedImage_0.png

961 Views
vishalgirisagar
Contributor II

Hi Alice,

   I used the exact same code as given in typical application 1st case. I still do not get the DAC output. :smileysad:

I have quick follow up question.

Since DAC is 12 bit resolution, why is the example code setting 32 bit value?

#########################################################################################

Required component setup:

•Interrupt service/event: Disabled

•D/A resolution: 12 bits

•Data mode: unsigned 32 bits, left justified

•Data buffer: Disabled

•Enabled in init. code: yes

•Methods to enable: SetValue

#########################################################################################

#define DATA_LENGTH 10                                                  /* Output data array length */

LDD_DAC_TData OutputData[DATA_LENGTH] = {                               /* Output data array */

                                                 0x0, 0x1C71C71C,

                                          0x38E38E38, 0x55555554,

                                          0x71C71C70, 0x8E38E38C,

                                          0xAAAAAAA8, 0xC71C71C4,

                                          0xE38E38E0, 0xFFFFFFFC

                                        };

LDD_TError Error;

LDD_TDeviceData *MyDacPtr;

void main(void)

{

  ...

  MyDacPtr = DA1_Init(NULL);                                            /* Initialization of DA1 component */

  for (;;) {

    for (i = 0; i < DATA_LENGTH; i++) {

      Error = DA1_SetValue(MyDacPtr, OutputData[i]);                    /* Set converter output */

    }

  }

}

0 Kudos
962 Views
DavidS
NXP Employee
NXP Employee

Hi Vishal,

Please set the voltage reference in the DAC component to "external" from "internal".

I also added in a delay loop (polling) so it doesn't change too fast as I used a Voltmeter to watch the DAC output.

Regards,

David

0 Kudos
961 Views
vishalgirisagar
Contributor II

Hi David,

  Thanks a lot. That works. I really am very thankful to you.

Also a quick follow up question. Since DAC is 12 bit resolution, why is the example code setting 32 bit value?

0 Kudos
961 Views
DavidS
NXP Employee
NXP Employee

Hi Vishal,

You are welcome.  Glad you are up and running.

I think it is just code re-use and wasn't optimized for this particular DAC.

Regards,

David

0 Kudos