Can I change waveDAC8 freq at run time

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

cross mob
Anonymous
Not applicable

I have a CY8C3866-206 design where I utilaize the waveDAC8 component. With it I create two frequencies that are used at run time. I'd like the ability to set, or point to new, frequencies, based on a PCB address. For example; if a PCB is addressed at 1 then use (or generate) the two frequencies around 1khz. If addressed at 2 use (or generate) the two frequencies around 2khz.

   

Is there a way to feed the waveDAC8 a constant freq (say 5khz) then divide (or subtract from) that freq based on PCB address?

   

I am not stuck on using waveDAC8. If there is another viable method (PWM??) I'm open for suggestion.

0 Likes
6 Replies
MarkH_61
Employee
Employee
25 likes received 50 replies posted 25 replies posted

Yes you can change the WaveDAC8 sample frequency during runtime.  You can either access the internal clock and change it but, I recommend to use the external clock option instead.  If you enable the external clock option, you can alter the clock however you wish, as long as you don't exceed the update rate of the internal viDAC.

   

 

   

Mark

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

You can use the WaveDac8 with an external clock that could be generated by a Timer component. The period of the timer can be changed by the program to adapt the frequency to your needs.

   

 

   

Bob

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

@meh

   

Crossover post, luckily we have the same opinion

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thanks for both replies!

   

So, I've added a clock component (5khz == 'base' freq) and enabled the external clock on the waveDAC8.. But I'm drawing a blank on how to change that 'base' freq to drive the DAC. Would I add an interrupt to the 'base' freq then manipulate it in software (or perhaps use a MUX?),  then clock the DAC ck pin? In any event, I don't see how to clock the DAC from a function call. Finally, once the DAC is clocked how is the putput controlled? 1) by calling waveDAC8_Enable() , and/or 2) by the external clock (where is there is no clock the DAC wont produce output.  Which of those is the prefered method?

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

I suggested "...external clock that could be generated by a Timer component".

   

So use a timer and feed it with 24MHz (to get some headroom).The WaveDac clock must be your desired frequency * Number of Samples (from WaveDac property window). Set the timer's period accordingly. When you start all components everything will run freely without CPU intervention. Decide yourself when (Button press, slider move) you want to change timer's period.

   

 

   

Happy coding

   

Bob

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

The Wavedac, at its most basic level, is a table of waveform values for one

   

period, and a DMA engine that takes those samples, consecutively, one

   

sample at a time, and send that to a DAC. The rate of the DMA and the size

   

of the table determine the frequency.

   

 

   

So easiest method is the timer approach, and it has APIs that set its divisor,

   

hence output clock rate to the Wavedac.

   

 

   

A more complicated approach is stop the wWavedac, and use its setup APIs

   

to determine waveshape and frequency.

   

 

   

So, I've added a clock component (5khz == 'base' freq) and enabled the external clock on the waveDAC8.. But I'm drawing a blank on how to change that 'base' freq to drive the DAC.

   

 

   

Right click component, pick datasheet, there is a secion on APIs to

   

control timer, its divisor, etc.. If you are just using a clock it has an

   

API to control its frequency.

   

 

   

Would I add an interrupt to the 'base' freq then manipulate it in software (or perhaps use a MUX?),  then clock the DAC ck pin?

   

 

   

Not necessary unless you want the freq change to be synch to some other event.

   

Just use period API for timer to set its output freq.

   

 

   

In any event, I don't see how to clock the DAC from a function call.

   

 

   

The Timer output is feed to Wavedac clock, and that triggers the DMA process.

   

 

   

Finally, once the DAC is clocked how is the putput controlled?

   

 

   

The Wavedac can be buffered by checking a property of it. That is an OpAmp

   

follower which you feed to a pin. Wavedac amplitude range is a tradeoff of table

   

values and 8 Bit DAC intrinsic range and Vref choosen.

   

 

   

 1) by calling waveDAC8_Enable() , and/or 2) by the external clock (where is there is no clock the DAC wont produce output.  Which of those is the prefered method?

   

 

   

Realy either, although if using timer might as well start that or gate its clock

   

to the Wavedac.

   

 

   

Regards, Dana.

0 Likes