Atmega 2560
F_CPU=16 Mhz
CodeVisionAvr
sine Table = 256
DAC0832
how can i generate frequency using Atmega 2560
A. What range of frequencies?
B. What frequency step size can you tolerate (granularity)?
The obvious answer is "DDS" but you will have to provide more information (the questions above) before any useful answer can be provided.
Jim
He didn't actually say what frequency or that it should be variable. Presumably a for() loop stuffing the sin[] table values out to the DAC would produce some frequency ;-)
Actually, you don't even need a DAC to generate a frequency. PWM out will do that, just fine.
By including "sine table = 256" in the spec, that tells us that a simple square wave is probably mot enough. "DAC" suggests the same, especially in combination with "sine .... "
No, the OP did not say that the frequency is to be variable. So, maybe lets back up slightly.
A. What frequency or range of frequencies?
B. If a single frequency, how accurate? If a range of frequencies, what frequency step size can you tolerate (granularity)?
C. Do you want all 256 steps of the sine table to be present in every cycle of the generated signal?
Jim
Maybe he wants to play 3 or 4 of the sine waves to get a pleasing waveform?
I peeked at the info for that chip. Very suitable for 8080 apps. ;) Memory-mapped would work best? If so, then it would seem to be a simple adjustment of jesper's miniDDS after getting the external memory interface going.
That is true.
BUT, the solution will be very different if the OP wants 200KHz sine with 256 samples per cycle (256 samples in 80 clocks), vs 62.5KHz at 256 samples (1 sample per clock) vs 50Hz at 256 samples.
That is why frequency or frequency range is so important.
Jim
Thank you very much. For helping me.
I am new to AVR MCU.
Please help me find a solution.
I want to create a sine signal at best.
At http://www.myplace.nu/avr/minidd...
I do not understand.
Resolution = fCPU/150994944 and
fOut = Accumulator * Resolution
150994944=?
At http://www.myplace.nu/avr/minidd...
I do not understand.
Resolution = fCPU/150994944 and
fOut = Accumulator * Resolution
150994944=?
The "Mini DDS" looks like a perfect shortcut for your project. Only problem is you need to understand some assembler, but since the code is fairly well-documented you should be able to manage that.
The value can also be calculated from 150994944.
why=150994944
150994944 = 0x9000000 if it helps?
150994944 = 0x9000000 Where it came from.
150994944 = 0x9000000 Where it came from.
the assembler source code
This comment in particular:
; Output frequency (using 24 bit accumulator) : ; ; f = deltaPhase * fClock/2^24 ; ; fClock is in this case the CPU clock divided by the ; number of cycles to output the data ( 9 cycles ) ; ; f = r24/r25/r26 * (11059200/9)/16777216 ; ; f = r24/r25/r26 * 0.073242188 ; ; fMax (theoretical) = 0.5 * fClock
Oh and 2^24 = 0x1000000 = 16777216
Actually, you don't even need a DAC to generate a frequency. PWM out will do that, just fine.By including "sine table = 256" in the spec, that tells us that a simple square wave is probably mot enough. "DAC" suggests the same, especially in combination with "sine .... "
No, the OP did not say that the frequency is to be variable. So, maybe lets back up slightly.
A. What frequency or range of frequencies?
B. If a single frequency, how accurate? If a range of frequencies, what frequency step size can you tolerate (granularity)?
C. Do you want all 256 steps of the sine table to be present in every cycle of the generated signal?
Jim
A. 1Hz - 1Khz
B. range of frequencies (How to accurate frequency)
C. yes i want 256 steps every cycle
How will you be able to tell if there are 256 steps? It will still look like a 1KHz sine wave with 16 steps per cycle.