Problems with the ADC channels reading KL25Z.

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

Problems with the ADC channels reading KL25Z.

Jump to solution
2,586 Views
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 Solution
1,582 Views
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!

View solution in original post

0 Kudos
Reply
4 Replies
1,583 Views
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 Kudos
Reply
1,582 Views
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 Kudos
Reply
1,582 Views
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,582 Views
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 Kudos
Reply