Reading ADC_LDD values

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

Reading ADC_LDD values

2,081 Views
yogesh8418
Contributor III

Hi

I have  TWR-K20D72M and I read the quick start pdf of the TWR-K20D72M .I am  Freescale MQX RTOS 4.0 BSP for TWR-K20D72M.

Now I want to read the ADC value which comes from the Potentiometer Already attach to the board. So I added ADC_LDD from processor expert and set the pin no. of the potentiometer mentioned in the Manual. My settings are shown in the picture attached. then I generate the code and build bsp.


My code for reading the value is below.


LDD_TDeviceData     *Analog_DeviceData;

LDD_TError           Analog;

LDD_TData           *Buffer_DAta;

static uint16_t value;

void Analog_task

(

  uint_32 initial_data

)

{

  puts("\nInitializing Analog device.....");

  Analog_DeviceData = AD1_Init(NULL);

  if (Analog_DeviceData == NULL)    {

  puts("failed");

  _task_block();

  }

  else {

  puts("done");

  }

  for(;;) {

  //AD1_StartLoopMeasurement();

  AD1_StartLoopMeasurement(&Analog_DeviceData); /* do conversion and wait for the result */

  AD1_GetMeasuredValues(&Analog_DeviceData,&Buffer_DAta); /* get the result into value variable */

   printf("\n - Buffer_DAta              = %d Hz", &Buffer_DAta);

   puts(Buffer_DAta);

  

  }

}

But no output Shown I change the value.

Can any one suggest me the efficient way of reading the ADC values using MQX and Processor Expert.

ADC Freescale.png

0 Kudos
Reply
2 Replies

1,534 Views
Monica
Senior Contributor III

Hello Yogesh,

was this suggestion helpful? Please keep us posted :smileywink:

Best,

Monica.

0 Kudos
Reply

1,534 Views
Ali_Pina
NXP Employee
NXP Employee

Hi Yogesh,

I would suggest that you take a look to “CW for Microcontrollers v10 and MQX” which can be found at this path:

C:\Freescale\Freescale_MQX_4_0\doc\tools\cw

In page 64 you will find an explanation on how to add a new driver and specifically how to add ADC_LDD component.

I just ran a test using the pe_demo and added a task and it works with no issues. I am attaching the main.c file for your reference.

Hope this helps.

-Alí

0 Kudos
Reply