DMA and PIT for FRDM K64F board

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

DMA and PIT for FRDM K64F board

7,280件の閲覧回数
kirantujare
Contributor IV

I'm working on a project where I'm trying to design a frequency generator. I want to use DMA and PIT(Periodic Interrupt Timer) feature on FRDM K64F board. I would like some help on the use of these on FRDM K64F board using KSDK+PE. I am using KDS Version: 3.2.0 and KSDK 1.3.

ラベル(3)
25 返答(返信)

5,536件の閲覧回数
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Kiran

You could tried this way

for(index = 0 ; index z buffer_size ; index++)

    {

        DAC_DRV_Output(FSL_DACONV1,q[index]);

    }

If you have with the output, let me know

Mario

0 件の賞賛
返信

5,536件の閲覧回数
kirantujare
Contributor IV

Hi Mario,
I wanted to direct you to another question I have Pulse generator on FRDM K64F board .
Please take a look at your spare time.
Thank you.

0 件の賞賛
返信

5,536件の閲覧回数
kirantujare
Contributor IV

Hi Mario,

My code works perfectly and the output is shown on the oscilloscope. The only problem is that the data doesn't show continuously on the scope. I get the stream of ones and zeros(square wave) and then it flats out. I want the continuous flow of square wave. I get the expected wave after putting it in an infinite 'for' loop but the next line of code doesn't run. Please let me know if you have any suggestion/solution for it? I have the code below

0 件の賞賛
返信

5,536件の閲覧回数
kirantujare
Contributor IV

Hi Mario!

It does work. Thank you so much for your help :smileyhappy:

0 件の賞賛
返信

5,537件の閲覧回数
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Kiran,

I took a look of the code and the signal, the PIT and DAC configuration are correct, but I recommend use different buffers for each signal, or make test with constant values and select one signal buffer to the DAC _out.

This example show you how to create the sine signal, using PIT + DAC. Some recommendations to calculate the data for the signal with constant values.

https://community.freescale.com/message/642235?et=watches.email.thread#comment-642235

Hope it Helps

Mario Castañeda

0 件の賞賛
返信

5,537件の閲覧回数
kirantujare
Contributor IV

Hi Mario,
I just found out that my 7200 data points get halved ( 3600) after sending them over to DAC.
Do you know why this would happen? I have attached the screenshot. After using this line of code the datapoints are halved

0 件の賞賛
返信

5,536件の閲覧回数
colin
Contributor III

The reason only half the points are being processed is that the index variable is being incremented an extra time by the ++ operator in the array dereference...

You probably have fixed this and moved on, but I thought I would answer the question just in case.

0 件の賞賛
返信

5,536件の閲覧回数
kirantujare
Contributor IV

Thank you Colin. I have resolved it :smileyhappy:

0 件の賞賛
返信

5,537件の閲覧回数
kirantujare
Contributor IV

Thank you Mario. I got it all figured out. I am getting the output correctly. The only thing is I want to see it on two separate channels. Since I am using only using DMA+PIT, I don't know how to get the output on two separate channels. Still trying to figure out a way to do that.

0 件の賞賛
返信

5,537件の閲覧回数
kirantujare
Contributor IV

Hi Mario,
Can you answer this thread please?
USB CDC for Custom Board 

0 件の賞賛
返信

5,537件の閲覧回数
kirantujare
Contributor IV

Thank you. I will try doing that and let you know how it goes.
The link redirects to the same page.

0 件の賞賛
返信

5,538件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Hi Kiran,

Looks like you are struggling with basic C programming here, and the compiler is correct to flag what you did.

Using 'extern' is a *declaration*, i.e. it makes the symbol known to the compiler.

use something like

extern int q[7200];

is fine.

It is *not* ok in C to initialize a declaration like you did with

extern int q[7200] = {0};

as you mix up a declaration and a definition:

- declaration: makes the type/name of the variable known to the program

- definition: defines and allocates the memory for the variable.

So you should use

extern int q[7200];

for example in the header file.

And in a C file (only there) you make the definition of it with

int q[7200] = {0};

and as this is the definition, you can initialize it.

So one message from the compiler is that you should not initialize a declaration, the other message is that you only had a declaration, but no definition.

I hope this makes sense,

Erich

0 件の賞賛
返信

5,538件の閲覧回数
kirantujare
Contributor IV

Hi Erich,
Thank you for the explanation.
I tried doing what you said as you can see the error in the screenshot 1 in the previous message. What could be the reason for it? I tried using extern int q[7200] in events.c as well as events.h file differently and I still get the error "undefined reference to 'q ' "

0 件の賞賛
返信

5,538件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Use

extern int q[7200];

in events.h

and

int q[7200] = {0};

in events.c

Erich

0 件の賞賛
返信

5,538件の閲覧回数
kirantujare
Contributor IV

Hi Erich,
Can you answer this thread please?
USB CDC for Custom Board 

0 件の賞賛
返信

5,534件の閲覧回数
kirantujare
Contributor IV

Thank you so much Erich! It helped a lot. It is working now.
I want to output 3 waveforms from DAC. Is it possible to do that?
I am using DAC0_OUT(Analog Out) Pin to check the waveform on scope and I see only one waveform. Which pins will be used to check multiple outputs.? Is there an alternative way to do that. I am an amateur. This is my first project. Please bear with me if I sound silly.
Please let me know

0 件の賞賛
返信

5,538件の閲覧回数
mario_castaneda
NXP TechSupport
NXP TechSupport

If you want to see the 3 output waves at the same time is not possible. The FRDM K64F the package 100 LQFP only has 1 DAC module.

Capture.2PNG.PNG

But if you want to get the different signals, you only have to do is select different channel for the 3 output waves depending the mux channel

Hope it helps

Best Regards

Mario Castañeda

5,538件の閲覧回数
kirantujare
Contributor IV

Thank you for the reply. Currently, I am using DAC + PIT on Processor Expert. I have no idea how to select DMA Channels. I also could not figure out how to get DMA working for KSDK+PE project. I am sending calculated values from user input to DAC using an array. I am not sure if the approach is correct.

0 件の賞賛
返信

5,538件の閲覧回数
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Kiran

The next KDS 1.3 examples will help you to understand the configuration of the different modules that you want to use, DMA and PIT after that, you can modify your project on PE.

In the next path you can find the examples of the modules

C:\Freescale\KSDK_1.3.0\examples\frdmk64f\driver_examples\edma

C:\Freescale\KSDK_1.3.0\examples\frdmk64f\driver_examples\pit

The next example shows the configuration of PIT and DMA, saving the information that is taken of ADC channel

https://community.freescale.com/docs/DOC-102951

Hope it helps

Best Regards

Mario Castañeda

0 件の賞賛
返信

5,537件の閲覧回数
kirantujare
Contributor IV

Thank you Mario!

I tried using DMA for a simple Sine wave and I got the correct output. However, I have to output 3 different waves for my project. I would like to know how I could make that work? Also, I want to use values from main.c file to trigger DMA in events.c file. How can I make that happen? Please let me know if you can provide any help whatsoever. I tried using "extern int q[50]" to access variable from main.c to events.c but it throws an error saying- " undefined reference to q"

0 件の賞賛
返信