AnsweredAssumed Answered

Using Two A/D's  FRDM-K22F

Question asked by brian cavanagh on Nov 25, 2017
Latest reply on Nov 27, 2017 by Robin_Shen

I created a program using one A/D (i know my question above states 2) and based on whether the A/D value is < 0x7fff (turn Red led on) and if the A/D value is >0x7fff (turn Yellow led on).

 

Now that I'm using two A/D's, I see a pointer is being used for each stored A/D value.

I'm not sure how to read "value[0]" and "value[1]".  I will use two leds for "value[0]" result, and another two for "value[1]" result.  The Red and Yellow criteria will be the same as above.

 

I commented out my LED-Code so I can step-through the program and observe what happens during the A/D process. 

 

Here's what I observed:

When I hovered over 'word' (in red) the 'value' was 0x0000 which is correct, since I adjusted pot1 so the input pin will read 0 volts. 

 

Likewise, when I hovered over 'word' (in blue) the 'value' was approximately 0xffff which is correct, since I adjusted pot2 so the input pin will read 3.3 volts.

 

This confirmed to me, that the program I created using two A/D's is working correctly.

 

Here's my struggle:

I'm not clear how to use the result from "value[0]", then light the led that determines if it's less than or greater than 0x7fff.  Similarly, the same holds true how to read "value[1]".

 

Below is my code for a successful measurement with two A/D channels.  You'll notice I have the LED-code commented out that was related to my single channel led test.  Of course, the uncommented code does not reflect the single channel A/D I used previously.

 

 

            Note:  I overlapped (void)AD1_GetValue16(&value[0]) in the screen capture for clarity to the reader.

                       Also, you will notice, below, in the commented code, how I determined whether the Red or Yellow                         led should turn on/off based on the A/D measurement.  This code did work for the signal A/D                         measurements.

 

 

 

Thanks,

 

Brian

Outcomes