[FRDM-KL26Z] Can the MCU accept negative voltage inputs for ADC?

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

[FRDM-KL26Z] Can the MCU accept negative voltage inputs for ADC?

Jump to solution
1,204 Views
david_lee
Contributor II

Hi, I'm using FRDM-KL26Z board with IAR EWARM 7.20.

I just bought this board and I'm new to it. I want to use the 16 bit ADC.

I'm curious whether the MCU can accept negative voltages at the ADC input pins.

For instance,

I want to plug a sine wave

(-1 ~ 1 volts peak-to-peak which has frequency of 1000) using a function generator.

Can the MCU read the negative voltages and convert it?

If so, what configurations are needed?

- Best Regards, David

Labels (1)
Tags (2)
1 Solution
884 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David Lee,

      Now answer your questions.

    Actually, the sign bit of the ADC data register  is just for the diff mode, because just the diff mode has  a pair of external pins, DADPx and DADMx, when do ADC diff conversion, it actually convert the DADPx-DADMx,  if the DADPx higher than DADMx, the result is positive, if the DADPx is lower than DADMx, the result is negative, then it will use the sign bit.

    Your problem is very simple to solve, you just need to use the 16 bit differential mode, connect "input 0" to DADPx, connect "input 1" to DADPMx, then you will get the diff data of your input0 and input1 in the ADC data register, and it should have the sign bit.

Wish it helps you!

If you still have question, please contact with me!
Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
5 Replies
884 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David Lee,

    The KL26 can't accept negative voltage inputs for ADC, you can find it from the datasheet:

20.jpg

  So you should use the external circuit to keep your signal  between the VREFL - 31/32*VREFH.

  About the ADC sample code, please refer to the KSDK1.3.0,

  After you install the KSDK1.3.0, you will find the sample code in folder:C:\Freescale\KSDK_1.3.0\examples\frdmkl26z\driver_examples\adc16

Wish it helps you!

If you still have question, please contact with me!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
884 Views
david_lee
Contributor II

Thanks for the quick response.

sine.png

Then, in this case, suppose there is a signal like "input 0" in the picture.

The sine wave is now biased with a DC voltage (1.5 Volts).

"Input 1" is a DC voltage source of 1.5 Volts.

I never used the "DIFF" mode before, so my ideas may have errors.

I know that the 16 bit ADC has sign bits, if I configure them.

Then can the ADC pins can read both "input 0" and "input 1" and use the diff mode

,in order to get rid of the DC component and read it as singed inputs?

In other words, I'm curious why the ADC data register has a sign bit although the ADC peripheral cannot read negative voltages.

0 Kudos
885 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David Lee,

      Now answer your questions.

    Actually, the sign bit of the ADC data register  is just for the diff mode, because just the diff mode has  a pair of external pins, DADPx and DADMx, when do ADC diff conversion, it actually convert the DADPx-DADMx,  if the DADPx higher than DADMx, the result is positive, if the DADPx is lower than DADMx, the result is negative, then it will use the sign bit.

    Your problem is very simple to solve, you just need to use the 16 bit differential mode, connect "input 0" to DADPx, connect "input 1" to DADPMx, then you will get the diff data of your input0 and input1 in the ADC data register, and it should have the sign bit.

Wish it helps you!

If you still have question, please contact with me!
Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
884 Views
david_lee
Contributor II

Great, this was the feature I was looking for.

I will choose your answer after I check one more thing.

I'm new to Freescale (now it's NXP) MKL series.

Is there a example using DIFF mode?

Couldn't find them at the basic examples at IAR EWARM.

Also where can I get the latest SDKs?

I also use MKL16Z series, so I hope the SDK supports this chip as well.

0 Kudos
884 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David Lee,

  About the ADC sample code, please refer to the KSDK1.3.0,  Kinetis SDK rev 1.x

  After you install the KSDK1.3.0, you will find the sample code in folder:C:\Freescale\KSDK_1.3.0\examples\frdmkl26z\driver_examples\adc16\iar

  But this sample code is just the sigle-ended, if you wan to use the differential, you need to configure the ADC channel as the kAdc16Chn0 to kAdc16Chn3, then configure the diffential mode:

chnConfig.diffConvEnable = true;

    You can try to modify the code, and associate with the KL26 reference manual

    About the KL16, actually, the ADC module is the same as the KL26, the KSDK is also supporting the KL16, but it don't have the sample code directly, you should refer to the KL26 sample code, and modify the header file and the according code for KL16.

Wish it helps you!

If you still have question, please contact with me!
Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos