I have a project wrong,how can i debug it?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Dear all,

   

Now i have a project,following the process:1.WaveDAC8 can generate the sine wave.2.The output of  WaveDAC8 is the input of a ADC.3.Sending the ADC output to the filter by the DMA.4.I store the filter output datas into SRAM and display them on LCD.

   

But i can not get the sine wave datas on LCD which generated by WaveDAC8.You can download the project and test it.Now i want to debug it ,but the obvious phenomenon i can see maybe is the data stored into the sram.Dose any other ways i can find the errors? Thanks!

0 Likes
22 Replies
Anonymous
Not applicable

  Here the project.Because of the bad Internet,I have not uploaded it before. 

0 Likes
Anonymous
Not applicable

May be problem with the browser, try use IE.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable
0 Likes
lalec_300236
Level 1
Level 1
First like received

1. you have

   

int* dst  as global variable

   

and

   

   

int dst[100] in your main loop.

   

2. when you say cannot dispaly, what actually happen? you can see the

DATA:

on the display but not the value or it is showning something else?

 

 

 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

As L.L. said: remove the "int * dst" from program and move the definition

   

"int dst[100]" to the global variable area.

   

Have a look into the DMA-datasheet to see how sram-addresses should be defined in opposite to PSoC3 designs.

   

Debugging DMA is a bit complicated, since there is no instruction you can stop at. I would suggest to write and connect an interrupt that gives you a breakpoint to set at a complete DMA-transfer.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You might make the following changes -

   

 

   

1) Filter sample rate, 10 Khz

   

2) Filter window to blackman

   

 

   

This will get you a little more rejection, and less power consumption.

   

 

   

Use DMA wizard, under tools menu, to set your dma up and get code

   

to copy into your setup.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

@L.L,@Bob,@danaaknight

   

Yeah,i delete the int *dst,and set the int dst[100]to global variable area.Now no matter how i set the filter cutoff, the LCD only display two datas on it for a cycle.My ideal number of datas is 100.

0 Likes
Anonymous
Not applicable

 what do you mean by 2 data per cycle? and what do you expect those data are? 

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

@Mark: I guess you should tell a little bit about what you want to do. The LCD is not that fast, it might be updated 10 times per second.

0 Likes
Anonymous
Not applicable

 @H L,@hil,

   

       I just want to digitalize the sine wave generated by WaveDAC8,and store the datas into sram.And the sampled datas number is 100.I add a CYdelay() after the LCD_PrintInt8(),so i think it will update not to fast.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

What do you mean by "digitalize the sine wave".

   

As far as I understood you have a WaveDAC8, generating a sine wave. The output of the DAC is routed to an ADC, which in turn is connected to a DFB block. The DFB then stores the filtered result in sRAM.

   

But what is it that you want to display?

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

To digitize the sinewave, much like a DSO does, you can either do it in real time,

   

which means you oversample your waveform, or you can use equivalent time

   

sampling if you cannot sample fast enough. However this is limited to continuous

   

time signals, unlike real time sampling. Principles discussed in attachment.

   

 

   

Do you need, for any frequency input, it to always yield 100 samples for a single

   

cycle of the waveform ?

   

 

   

Note there are several example projects that show how to accompish DMA, here -

   

 

   

    

   

          http://www.cypress.com/?rID=37793     AN52705

   

 

   

Regards, Dana.

   

 

   

 

   

 

   

 

   

 

   

simply

   

sampl

0 Likes
Anonymous
Not applicable

1. I would also print out the array index to the LCD

   

2. What did you see from the LCD? BLANK? wrong value? some charaters but not numbers?......

0 Likes
Anonymous
Not applicable

 @hli,@danaaknight,@HL,

   

The filter is vain in this project,but i should use it in the nest step,so i put it on the topdesign.If i set the cutoff higher than the frequency of sine wave,it will not work ,doen't it?now,for example,i set the WaveDAC8 to generate a 100HZ sine wave ,if i set the conversion rate of ADC to 10000HZ,i can get 100 datas about the sine wave in one cycle,dosen't it?I need to save them to SRAM ,then read them on LCD.But ,i just see two datas on LCD,that's why?

0 Likes
Anonymous
Not applicable

What is two data?

   

you can see two values of data, ie 100 rams location are the same 2 bytes?

   

you can only see array dst[0] and dst[1]?

   

Can you list clearly what you see?

   

What did you see on the LCD? DATA: ?????

   

As I suggested you should print the indes so your LCD should print

   

DATA[0]:xxx

   

DATA[1]:xxx

   

...

   

DATA[99]:xxx

0 Likes
Anonymous
Not applicable

@ H L,

   

The sine wave is generated by the WaveDAC8,how can i judge whether the datas are sampled from the sine wave by the ADC?If i use the PWM way to generate the sine wave,the whole datas of the sine wave are listed by myself,so i can judge the datas whether i needed.So i don't know how to judge the two datas wether from the sine wave i needed.Can you point out the errors leading to the errors during the process of the whole project ?Thanks for your insisted help.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The Wavedac component has an end of cycle (1 period) output

   

signal. You could use that to take one cycle of sinewave readings

   

with ADC and then look at array of samples to see if it also has

   

1 cycle worth of data and is also a sine as you expect.

   

 

   

Use the wc1 output of wavedac, tie it to isr component, and at first

   

isr flip a pointer to an empty array, fill that array with samples, then

   

when next isr event occurs, flip pointer to another array which stops

   

filling array you just finsihed, and read the array you just filled with

   

one period/cycle of wavedac component.

   

 

   

Note however this only works if wavedac is in synch with A/D. So if

   

array is 100 samples, sine is 1 Khz, then A/D must be synch with

   

wavedac clock and running at 100 KSPS to exactly fill array with

   

100 +/- 1 sample.

   

 

   

This would confirm your sampling and dma is right.

   

 

   

The synch issue is aleviated by equivalent time sampling, in the Tektronix

   

ap note I posted.

   

 

   

Another way is to create a PLL to clock A/D running in single cycle mode,

   

but that is more complicated, implementing PLL.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 I cannot understand what is the meaning of two data? and why it is wrong? how do you know it is wrong? 

0 Likes
Anonymous
Not applicable

When I say "how to you know it it wrong: I mean

   

Are you expecting some value and the value is not what you expected?

   

And based on what you come up with your expected value?

0 Likes
Anonymous
Not applicable

Could you post your question in chinese, I can understand chinese, and can translate it you wish.

0 Likes
Anonymous
Not applicable

I need the editing function

   

"..., and can translate it to english - if you wish."

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Note, when I posted this -

   

 

   

Note however this only works if wavedac is in synch with A/D. So if

   

array is 100 samples, sine is 1 Khz, then A/D must be synch with

   

wavedac clock and running at 100 KSPS to exactly fill array with

   

100 +/- 1 sample.

   

 

   

This is true if you want, for any input frequency, exactly 100 samples/

   

single cycle of input waveform. Otherwise as long as you sample at Nyquist

   

or better you will have a varying sample length in array for any given

   

cycle of the input waveform.

   

 

   

Regards, Dana.

0 Likes