How to configure differential ADC on K22FN1M0

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to configure differential ADC on K22FN1M0

跳至解决方案
2,413 次查看
ARQuattr
Contributor IV

I am using the MQX4.1 lwadc based on the example code for the twrk21f120m board, and for single-ended readings it appears to work fine.  But I also have a differential input on a custom board I want to use and I'm not sure how to set that up.

The source I'm using is ADC0_SOURCE_ADPM1 (pins 14 an 15 on the 100pin K22).  This source (according to adc_mk21f.h) includes the ADC_SOURCE_DIFF flag, so I was hoping it would work without extra effort, but it looks like I'm getting only a single-ended reading.

If I call _lwadc_get_attribute(lwadc_ptr,LWADC_DIFFERENTIAL,&value), I get a response of 0.  If I try to set it (calling _lwadc_set_attribute(lwadc_ptr, LWADC_DIFFERENTIAL, 1)), I get an error.

Are there some other flags or configuration I need to do to get differential readings?

Thanks,

Angelo

标签 (1)
标记 (4)
0 项奖励
回复
1 解答
1,911 次查看
santiago_gonzal
NXP Employee
NXP Employee

Hello Angelo,

Have a look at the SDK, it has drivers for the ADC and it supports differential mode.

For the moment K64,23 and 24 are the only supported, but in the next revision K21 and K22  120 MHz will be supported. But the registers for the ADC are the same, so you will probably be able to reuse most of it.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KINETIS_SDK

Regards,

Santiago

在原帖中查看解决方案

0 项奖励
回复
5 回复数
1,911 次查看
ARQuattr
Contributor IV

Gee, nice!

Well thanks for saving me more time on this.  I'll try Processor Expert, or maybe just write my own simple driver.  Or maybe I'll just read each one single-ended and take the difference, although I was hoping for a simultaneous read.

Has anyone else written some simple direct register access code to configure and read differential ADC?

Thanks

0 项奖励
回复
1,912 次查看
santiago_gonzal
NXP Employee
NXP Employee

Hello Angelo,

Have a look at the SDK, it has drivers for the ADC and it supports differential mode.

For the moment K64,23 and 24 are the only supported, but in the next revision K21 and K22  120 MHz will be supported. But the registers for the ADC are the same, so you will probably be able to reuse most of it.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KINETIS_SDK

Regards,

Santiago

0 项奖励
回复
1,911 次查看
santiago_gonzal
NXP Employee
NXP Employee

Angelo,

Just as an update, the SDK 1.0.0 has been released in the web. It has examples for K22 120 MHz.

Regards,

Santiago

0 项奖励
回复
1,911 次查看
richardtseng
Contributor I

We ran into the same problem trying to use lwadc to read differential ADC on K60.

Does FSL have plan to add K60 support to SDK ?

Have anyone try adding differential ADC to lwadc ?

Thanks,

Richard

0 项奖励
回复
1,911 次查看
santiago_gonzal
NXP Employee
NXP Employee

Hello Angelo,

If you dig into the code you will see differential pair is not supported in MQX:

\Freescale_MQX_4_1\mqx\source\io\lwadc

File lwadc_kadc.c, line 491:

        case LWADC_DIFFERENTIAL:

            /* We don't support differential, so return FALSE if asked for it, TRUE otherwise */

            return !value;

Have you tried with Processor Expert? I believe it supports differential pair ADC.

Regards,


Santiago