piclist 2002\09\20\094749a >
Thread: Challenge: FIR Filter on an 18f series device
face BY : Scott Dattalo email (remove spam text)

On Fri, 20 Sep 2002, Tony K|bek wrote:

> Hi,
> Scott Dattalo wrote :
> <snip>
> >How efficiently can this be implemented in assembly:
> >

> So, sensei :) here are my humble stumblings, untested, etc..
> I'll probably made some terrible misstakes but here goes:
> A: weight can be aligned anywhere
>    data_buffer is aligned on an 32 byte boundary (&data_buffer[0] has
> lowest five bits zeroed )
>    MAX_DATA_SAMPLES must be 16, and FIR_WEIGHTS must be less then 16


> B: weight and data_buffer located anyware in ram
>    MAX_DATA_SAMPLES and FIR_WEIGHTS can be arbitrary ( but less than 256
> )

This is certainly more useful.

>         CLRF    sum_l
>         CLRF    sum_h
>         LFSR    0,weights
>         LFSR    1,data_buffer+FIR_WEIGHTS
>         MOVF    data_index,W
>         MOVF    PLUSW1,F
;         ^^^^^^^^^^^^^^^^^ ???
{Quote hidden}

Hint: If you align "weights" properly too, you can get rid of "i" and use
FSR0L as your loop counter!

       CLRF    sum_l
       CLRF    sum_h
       LFSR    0,weights+FIR_WEIGHTS-1
       LFSR    1,data_buffer+FIR_WEIGHTS-1
       MOVF    data_index,W
       ADDWF   FSR1L
       BCF     FSR1L,5
       MOVF    POSTDEC1,W
       MOVF    PRODL,W
       ADDWF   sum_l,F
       MOVF    PRODH,W
       ADDWFC  sum_h
       BTFSS   FSR0L,3
        bra    FIR_A2_LOOP

{Quote hidden}

;         ^^^^^  That's clever!

>         MOVF    POSTINC1,W
>         MULWF   POSTINC0
>         MOVF    PRODL,W
>         ADDWF   sum_l,F
>         MOVF    PRODH,W
>         ADDWFC  sum_h
>         DECFSZ  i,F
>         GOTO    FIR_B_LOOP

This is what I was thinking about:

       CLRF    sum_l                   ;sum = 0
       CLRF    sum_h
       LFSR    0,weights+FIR_WEIGTHS-1 ;FSR0 -> Fir weights
       LFSR    1,data_buffer           ;FSR1 -> data
       MOVLW   FIR_WEIGHTS             ;i is the loop counter
                                       ; (we'll count down)

       MOVWF   i
       MOVFF   PLUSW0,temp             ;temp = weights[i]
       SUBWF   data_index,W            ;W = data_index-i
       ANDLW   DATA_INDEX_MASK         ;circular buffer
       MOVF    PLUSW1,W                ;W = data[data_index-i]
       MULWF   temp                    ;weights * data
       MOVF    PRODL,W                 ;
       ADDWF   sum_l,F                 ;sum += weights*data
       MOVF    PRODH,W                 ;
       ADDWFC  sum_h,F
       DECFSZ  i,W
        bra    FIR_C_LOOP


http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

<Pine.LNX.4.44.0209200557550.20980-100000@ruckus.brouhaha.com> 8BIT

In reply to: <8A2A45D3D18D574484CFD980CDB73A31024B5D@flmail.dns.flintab.se>
See also: www.piclist.com/techref/microchip/math/filter.htm?key=filter
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) Challenge: FIR Filter on an 18f series device

month overview.

new search...