Author Topic: [beginner]: KL03 MCU - Configuration of ADC  (Read 216 times)

0 Members and 1 Guest are viewing this topic.

Offline raff5184

  • Regular Contributor
  • *
  • Posts: 64
  • Country: us
[beginner]: KL03 MCU - Configuration of ADC
« on: December 06, 2017, 04:27:33 PM »
Hi all,
I am a beginner with microcontrollers, so I ask for your patience.
I need to use the ADC function of a Freescale KL03. From the reference manual I understood how it works and I found the definitions of all the ADC parameters in the code. However I can't find, in the code, where I can define my configuration for a specific mode of operation of the ADC.

For example, if I want it to work: hardware triggered, with continuous conversions and average on 4 samples, do I have to create my own function, or I just give the parameters in input to some function somewhere in the code? But where?
 

Offline ElektroQuark

  • Supporter
  • ****
  • Posts: 1162
  • Country: es
  • I was EdoNork
    • ElektroQuark
Re: [beginner]: KL03 MCU - Configuration of ADC
« Reply #1 on: December 12, 2017, 06:17:08 AM »
You have to use the NXP provided SDK, or create your own functions or write directly to registers.

Offline raff5184

  • Regular Contributor
  • *
  • Posts: 64
  • Country: us
Re: [beginner]: KL03 MCU - Configuration of ADC
« Reply #2 on: December 12, 2017, 07:07:56 AM »
thanks for your reply.
I actually already have the NXP SDK but it is not very clear how to initialize the ADC, especially if I want to use the pin PTA12
 

Offline ElektroQuark

  • Supporter
  • ****
  • Posts: 1162
  • Country: es
  • I was EdoNork
    • ElektroQuark
Re: [beginner]: KL03 MCU - Configuration of ADC
« Reply #3 on: December 12, 2017, 07:17:21 PM »
You will have to read the SDK help files them. It all depends on the SDK.
Sorry, I can help as I don't have experience with it.

Offline Geoff_S

  • Contributor
  • Posts: 42
  • Country: au
Re: [beginner]: KL03 MCU - Configuration of ADC
« Reply #4 on: December 12, 2017, 08:30:23 PM »
Have you looked at the SDK v2 ADC example ?  It should be fairly obvious how they've assigned the ADC pin muxes etc from the main source file and board.c/board.h.
 

Offline uTasker

  • Newbie
  • Posts: 4
  • Country: ch
Re: [beginner]: KL03 MCU - Configuration of ADC
« Reply #5 on: December 13, 2017, 10:44:24 AM »
Hi

If you choose the ADC0_SE0 channel and don't touch PTA12 for any other peripheral function it will automatically be there.
This is because PTA12 defaults to the ADC0_SE0 (analog function).

In case you have been using this pin for something else previously, example a GPIO or timer output, you can reprogram it to its (default) ALT0 function again in the PORTA_PCR12 register - i.e PORTA_PCR12 &= ~0x00000700; (setting the MUX mask back to 0 -> ALT0 function).

If you want hardware triggering pf the ADC conversion you will need to program a trigger from one of the possible TPM trigger sources - it is best to get it working in software triggered mode before moving to HW triggering.

Regards

uTasker

KL03: http://www.utasker.com/kinetis/FRDM-KL03Z.html
« Last Edit: December 13, 2017, 10:47:29 AM by uTasker »
 
The following users thanked this post: raff5184


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf