PIT- ADC- DMA Example for FRDM-KL25z, FRDM-K64F, TWR-K60D100 and TWR-K70

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

PIT- ADC- DMA Example for FRDM-KL25z, FRDM-K64F, TWR-K60D100 and TWR-K70

PIT- ADC- DMA Example for FRDM-KL25z, FRDM-K64F, TWR-K60D100 and TWR-K70

Hi community!!

The following example uses a PIT to start an adc conversion, once the conversion has finished it issues a DMA request and the DMA controller stores the converted value in a buffer. The examples were implemented in both CodeWarrior 10.6 and KDS 1.1 for every board.

The recommended test circuit is the following:

k64.PNG.pngKl25.PNG.png

Please feel free to modify the files, I hope this examples will be useful for you and will help you by decreasing your development time.

Best Regards

Manuel Rodríguez

Technical Information Center Intern

附件
评论

Hi Manuel,

Thanks for this demo!

This was kind of what i was searching.

Best regards

Christian

Hi Christian,

Glad to know it is useful!

Please do not hesitate to ask if any doubt arises.

Best Regards

Manuel Rodríguez

Hi Manuel,

Okay, Thanks!

It was very easy to apply your code for my goals. Everything works as intended. :smileyhappy:

If I've another challenge on this kind of area then I'll ask you.

Best regards

-Chris

Hi Manuel,

i would like to use the same functionality in MQX-Lite with an FRDM-KL25Z Board. Is it possible to get an example for this?

Thank you and best regards

Menko Oldewurtel

Hi Menko,

Unfortunately I do not have an example right now that uses MQX-Lite, I might be able to work out a project that uses Processor-Expert so that you can later on add MQX-Lite. Please let me know if this would be of any help for your application.

Best Regards

Manuel Rodríguez

Hi Manuel,

the idea with PE sounds good. It should be no problem for me to migrate it then to my MQX-lite application.

Thank you!

Best Regards

Menko Oldewurtel

Hi Manuel,

Do you have also an example for the comparator?

I didn't find an example in the SDK demos and also in the forum is none example available yet.

Best regards,

Chris

Hi,

There is not CMP KSDK example available yet, but in the KSDK documentation folder (C:\Freescale\KSDK_1.1.0\doc) you can find the Kinetis SDK API Reference Manual, in the section CMP Peripheral Driver you can find an example to initialize and configure the CMP driver for typical use cases.

I hope this information can help you.

Best Regards,

Adrian Sanchez Cano

Technical Support Engineer

Hi, when you are calculating the value to load into PIT_LDVAL0, you assume the clock to be 20MHz. Is this a default value, or is it something you have configured?

Thanks.

Hi Lily,

It is an assumed value immediately after reset (stated value in the reference manual Table 24-19 for KL25z and table 25-17 for K64F implies a value of 21MHz my mistake, sorry). You can easily modify it as per your convience. You can do this by modifying the MCG configuration.

Regards,

Manuel

Could you update this for Processor Expert and KDS 2.0.0? That would really help me out!

Thanks Manuel,

Thanks for share

It really helped me

Regards

hii manuel,

i cant find code of uart, just ADC PIT DMA and main.c . how can i know output of ADC?

regards

If I recall correctly I used the variable window watch in the debugger perspective.

Regards,

Manuel

what your mean about debugger perspective? i dont know where is variable window, sorry i am newbie.

is it using uart?

No problem, that is the perspective that opens in codewarrior after you flash the device, Live View for Variables and Memory | MCU on Eclipse   take a look at that link for more information. It is not using uart. I highly recommend you to take a look at this thread Using the DMA module in Kinetis Devices

ok thanks..

unfornatelly, i am confuse with many sample. perhaps you have sample for FRDM k64F with IDE KDS 3 and SDK 1.2.

It can be easily ported to KDS 3, but it was developed for CW and KDS 2.0 I think. No SDK was used it is a bare metal implementation.

oh i see..i must learn baremetal (basic code-*register) to access register ADC, DMA and etc facility in K64F.

for the example in Baremetal code examples using FRDM-K64F .

its important to know when we are newbie.

This is really great - this example. I'm a newbie and got this example to work after importing the kl25z project portion (contained in the downloaded zip file) into Kinetis Design Studio 3.0.0. At first, I got an error that said:

arm-none-eabi-g++: error: unrecognized command line option '-nanolibc'

make: *** [dma_pit_adc_kl25z_kds.elf] Error 1

But after looking on the internet, Enrich Styger in a freescale forum said that - due to a tool chain change, you got to replace the option -nanolibc with the following line:

--specs=nano.specs --specs=nosys.specs

Everything worked nicely after carrying out the above change in the area "C/C++ Build -> Settlings -> Cross Arm C++ linker -> Miscellaneous -> Other linker flags".

Glad to know it is useful!

Thanks!

Manuel

Hi Manuel! After having recently done and learned some basic things (LED and UART serial comms learning) with the KL25Z, I'm now going to try out ADC functions. I was looking at your code in main.c, and I see a line: "avg += value[i];"

I traced "value" back to dma.h, and so far cannot find out which process or function puts values or data into the elements of "value[i]". Is there meant to be some code that should be like value[i] = adc_read(); ?

Thanks Manuel!

Hi Kennyl,

The DMA is in charge of filling the buffer (value) with the results from the ADC conversion.

If you take a look to the dma_init() function you'll notice that the address from which the DMA reads the data is the ADC register (ADC0_RA) and the destination address is the start of the buffer "value".

Please take a look at the following thread to get a more thorough explanation of the DMA module:

Using the DMA module in Kinetis Devices

You can also use the adc driver alone with some modifications to the initialization routine such as commenting the line that enables the DMA. If you run into any issue please do not hesitate to ask!

Regards,

Manuel

Hi Manuel! Thank you very much for showing me Manuel. I was using the word search options within kinetis/eclipse and the search didn't find the word 'value', since I wrongly used the 'declarations' option, and should have use the 'reference' search option. I still wouldn't have quite understood everything, but what you kindly showed really helped me a lot to understand where the values come from now. Your tutorials and teachings are excellent. Thanks for your time and going out of your way to teach us Manuel. Greatly appreciated. Best regard. Kenny.

Thank you for your kind words! I am glad to know it helps!

Regards,

Manuel

Hi Manuel,

I've posted a separate issue but I found this example very useful. If I need high speed ADC conversions, this method seems to eat up a lot of CPU time due to the regular interrupts being called.

Is there a way to set up the ADC for continuous conversion without the need for an interrupting trigger (PIT in this case), i.e. just sample as fast as possible and use the DMA to push the values to a destination at periodic intervals?

I think you can configure it to run on continuous mode.

Hi

Your example helps lot while writing application. But I wanna read the two ADCs where each consists of 8 channels, I intend to read each ADC channel after every 50ms and send it to LCD once reading both channels are complete and repeat the process. Please can help out who do, I'm using MK60N512 .

Hello manuelroin

I'm trying to use the k64f and kds to read analog value from multiple inputs (7 analog inputs)

Can you provide any guidance on this?

无评分
版本历史
最后更新:
‎12-03-2014 11:37 AM
更新人: