Problems with the ADC channels reading KL25Z.

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

Problems with the ADC channels reading KL25Z.

跳至解决方案
2,591 次查看
josealonsovalle
Contributor III

Hi, i have been trying to read the ADC in the FRDM KL25, i can't read the channel ADC0_SE7b(PDT6) and ADC0_SE6b (PTD5),with other channels if i can read the ADC, but only with the PDT5 and PTD6 i had having problems.

Can somebody support me please???

this is my code.

Capture.PNG.png

greetings.

1 解答
1,587 次查看
mjbcswitzerland
Specialist V

Jose

if you want to sample ADC0_SE7b rather than ADC0_SE7a (which your code is doing) set the MUX selection bit to B in the ADC0_CFG2 register.

That is, add

ADC0_CFG2 |= 0x10;

after

ADC0_SC1A = ADC_SC1_ADCH(31);

For ADC0_SE6b the same MUX bit must be set (there is no ADC0_SE6a input on your device).

Regards

Mark

http://www.utasker.com/kinetis.html

P.S: The uTasker project also includes DMA driven ADC/DAC drivers for KL devices!

在原帖中查看解决方案

0 项奖励
回复
4 回复数
1,588 次查看
mjbcswitzerland
Specialist V

Jose

if you want to sample ADC0_SE7b rather than ADC0_SE7a (which your code is doing) set the MUX selection bit to B in the ADC0_CFG2 register.

That is, add

ADC0_CFG2 |= 0x10;

after

ADC0_SC1A = ADC_SC1_ADCH(31);

For ADC0_SE6b the same MUX bit must be set (there is no ADC0_SE6a input on your device).

Regards

Mark

http://www.utasker.com/kinetis.html

P.S: The uTasker project also includes DMA driven ADC/DAC drivers for KL devices!

0 项奖励
回复
1,587 次查看
avnergidron
Contributor III

Hi Mark,

Maybe you will be able to help me. I  am  new to FS.

I am using KDS and the PE on the same board and I  am facing the same problem. how  can  I read the ADC0_SE7b? (I understood I will need to change the mux but I am not sure how to do it in real time)

Thanks,

Avner

0 项奖励
回复
1,587 次查看
mjbcswitzerland
Specialist V

Avne

What do you mean with real-time?

To switch the input mux between a and b

ADC0_CFG2 &= ~0x10;

and

ADC0_CFG2 |= 0x10;

is all that is needed.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html

KL25: http://www.utasker.com/kinetis/FRDM-KL25Z.html / http://www.utasker.com/kinetis/TWR-KL25Z48M.html

ADC/DAC: http://www.utasker.com/docs/uTasker/uTaskerADC.pdf

For the complete "out-of-the-box" Kinetis experience and faster time to market

1,587 次查看
josealonsovalle
Contributor III

Thanks Mark, my program is working now, i don't know why my program was not function when i had ADC0_CFG2 |= ADC_CFG2_MUXSEL_MAKS; but when i indicated the direction in HEX the program coming to function correctly. 

0 项奖励
回复