ADC Scan operation in K22F

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

ADC Scan operation in K22F

569 Views
prasannanaik
Contributor III

Hi,

   

I want to use K22F series controller in a control application wherein i need to sample 12 ADC  channels on one trigger.

Basically i want  to use 2 DMA channels and ADC for this purpose. One DMA channel will put channel data into SC1A register of ADC. ADC will be configured in SW trigger mode and will give the output once SC1A contains channel information. The second channel will be used to store the result of ADC into a RAM buffer. I have referred  "Using DMA to Emulate ADC Flexible Scan Mode with SDK 2.x" but this application note has slightly different configuration. In application note, ADC is hardware triggered and channel data changes only on timer interrupt. So to sample 12 chanels 12 Timer interrupts will be needed. Thats why i am planning to use software trigger mode of ADC to sample 12 channels on one Timer interrupt whereing DMA sequencing will be started.

I have modified the code accordingly to sample 3 channels but it is not giving ADC interrupt. I couldn't figure whats wrong'. I have attached the code for reference. Please help.

Labels (1)
Tags (1)
0 Kudos
3 Replies

387 Views
nxf54945
NXP Employee
NXP Employee

Hi Prasanna,

 

ADC interrupts occur under the following conditions:

  • ADCn interrupt is enabled at NVIC and its dynamic priority is above the threshold.
  • The field “AIEN” is set at ADCx_SC1n.
  • The system is not currently processing a higher priority interrupt.

In order to request an ADC conversion, you need to write into ADCx_SC1n. If you use a DMA channel to write into these registers, you need to consider that every DMA transfer will overwrite the contents of ADCx_SC1n configuration fields. So you need to make sure that the data you are transferring into ADCx_SC1n contains the “ADCH”, “DIFF”, and “AIEN” settings you want to keep.

This way you will be able to request conversions and maintain settings according to your application demands. If the ADC interrupt criteria is met, ADCn will trigger an interrupt upon conversion completion. Remember to read the Rn register inside your ADC_IRQ in order to clear the COCO flag and avoid being interrupted multiple times by the same conversion.

 

Best Regards,

Javier

0 Kudos

387 Views
prasannanaik
Contributor III

Hi Javier,

   Thanks for your input.

   Actually the problem was in DMA configuration, i was giving start command to only one channel because of which i was not able to get the expected functionality.

   I am facing a different issue now.

   I am trying to verify the perfomance of ADC in this DMA ADC linking configuration but i am getting strange observations. I have applied 1.6V DC to 3 channels of ADC(i.e. Channel 8, channel 9 and channel 15) without any ripple(2 mV ripple observed on digital oscilloscope.Also there is no ripple on VDD.I haveconnected 0.1 uF  on all the channels.

Observations:

1) Testing on Personal computer, fluctuation in ADC o/p is 17-21 counts on all the channels

2) Testing on Laptop, fluctuation in ADC o/p is 2-4 counts on all the channels

I have never experienced this for other microcontrollers.

What could be the reason for this strange behavious and how do i test the performance of ADC?

Thanks and best regards,

Prasanna

0 Kudos

387 Views
nxf54945
NXP Employee
NXP Employee

Hi Prasanna,

No problem. I am glad to hear that you could solve the sampling issue.

Regarding the noise you are receiving on your signal, are you using one of our boards?

I found an AppNote about increasing ADC accuracy that may come handy. Here you will find the link to it: https://cache.nxp.com/docs/en/application-note/AN5250.pdf

Also, I suggest consulting our Kinetis Peripheral Module Quick Reference: https://cache.freescale.com/files/32bit/doc/quick_ref_guide/KQRUG.pdf
There you will find the steps to configure the ADC according to you application’s demands, as well as example bare-metal code that may help set your system for low noise conversions.

Best Regards,

Javier

0 Kudos