piclist 2004\04\20\191117a >
Thread: Looking for an AVR FFT tutorial
face BY : Mark Jordan email (remove spam text)

On 21 Apr 2004 at 8:52, @spam@Richard.Prosser@spam@spamPOWERWARE.COM wrote:

> The web site I used for my initial code was (I think)
> http://www.8052.com/users/steve/FFTC.C, which is an FFT example for the
> 8052 micro.

       Thanks, that seems to be a very good example!

> As far as comparing the Goertzel algorithm with the FFT I think it is a
> question of what you are actually trying to do.
> My impression is that the Goertzel algorithm aims at identifying a single
> frequency component in a signal, basically using a IIR filter. It is
> capable of running more or less "on the fly" once a certain number of
> samples have been obtained.

       I do the eight filters at every sample. When I reach N samples,
I compute the eight magnitudes and get the two DTMF frequencies. The
whole process used less than 20mS at 4MHz clock.

> Incidentally, I'd be interested in looking at you Goertzel implementation
> if possible!

       Here is a MACRO I used at every sample, based on that article at:


; At every sample, calculate for each frequency:
; Q0 = (coeff*Q1)/32768-Q2+sample
; Move Q1 to Q2
; Move Q0 to Q1
.macro SAMPLE                                   ; Q1l,Q1h,Q2l,Q2h,Coeff
               ldi     auxl, LOW(@4)
               ldi     auxh, HIGH(@4)
               lds     matl, @0
               lds     math, @1
               muls    math, auxh              ; (signed)Q1h * (signed)Coeffh
               movw    genl, prdl

               mul     matl, auxl              ; Q1l * Coeffl
               mov     intemp, prdh

               mulsu auxh, matl                ; (signed)Coeffh * Q1l
               sbc     genh, zero
               add     intemp, prdl
               adc     genl, prdh
               adc     genh, zero

               mulsu math, auxl                ; (signed)Q1h * Coeffl
               sbc     genh, zero
               add     intemp, prdl
               adc     genl, prdh
               adc     genh, zero              ; (Q1*Coeff)>>16

               lsl     genl
               rol     genh                            ; (Q1*Coeff)<<1

               lds     auxl, @2
               lds     auxh, @3
               sub     genl, auxl
               sbc     genh, auxh              ; Sub Q2

               add     genl, XL
               adc     genh, XH                        ; Add current sample

               sts     @0, genl
               sts     @1, genh                        ; Q1 = Q0

               sts     @2, matl                        ; Q2 = Q1
               sts     @3, math
.endmacro                                               ; 45 clock cycles
; After N samples, calculate for each frequency:
; MAG = SQRT(Q1*Q1+Q2*Q2-(Q1*Q2*coeff)/32768)

       Mark Jordan

http://www.piclist.com hint: To leave the PICList

<408582E8.12393.B0F0A10@localhost> 7BIT

In reply to: <OFF0BAAB9D.9724A2AE-ONCC256E7C.006E0E85@psd.invensys.com>
See also: www.piclist.com/techref/logic/dsps.htm?key=fft
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Looking for an AVR FFT tutorial

month overview.

new search...