


pctl      equ     $fffd
bcr       equ     $fffe                            ;BCR Register
ogdbr     equ     $fffc                             ;OnCE GDB Register
ecsr      equ     $ffeb                             ; EMI Control/Status Register
edrr0     equ     $ffea                             ; EMI Data Read Register
ebar0     equ     $ffe8                             ; EMI Base Address Register 0
eor0      equ     $ffe9                             ; EMI Offset Register
edrf      equ     13                                ; EMI EDRR Full flag
hrne      equ     17                                ; SHI FIFO Not Empty flag
hrx       equ     $fff3                             ; SHI HRX FIFO
hcsr      equ     $fff1                             ; SHI Control/Status Register
hi2c      equ     1                                 ; SHI IIC Enable Control Bit
ma        equ     0                                 ; OMR Mode A
mb        equ     1                                 ; OMR Mode B
mc        equ     4                                 ; OMR Mode C
gpior     equ     $fff7                             ; GPIO Control/Data Register
gdd3      equ     9                                 ; direction bit for GPIO3
gd3       equ     1                                 ; data bit for GPIO3
rcs       equ     $ffe1                             ;SAI receiver control / status register
tcs       equ     $ffe4                             ;SAI transmitter conntrol /status register
brc       equ     $ffe0                             ;baud rate control register
rx0       equ     $ffe2                             ;SAI receive data register
rx1       equ     $ffe3                             ;SAI receive data register
tx0       equ     $ffe5                             ;SAI transmit data register
tx1       equ     $ffe6                             ;SAI transmit data register
tx2       equ     $ffe7                             ;SAI transmit data register
ipr       equ     $ffff                             ;interrupt priority register
rldf      equ     14
rrdf      equ     15


N         equ     80







           org     p:$0                              ; bootstrap code starts at $0
           jmp     start1

wspolczynniki:
  dc      0.0000
  dc     -0.0006
  dc      0.0000
  dc     -0.0008
  dc      0.0000
  dc     -0.0013
  dc      0.0000
  dc     -0.0021
  dc      0.0000
  dc     -0.0030
  dc      0.0000
  dc     -0.0043
  dc      0.0000
  dc     -0.0059
  dc      0.0000
  dc     -0.0079
  dc      0.0000
  dc     -0.0105
  dc      0.0000
  dc     -0.0136
  dc      0.0000
  dc     -0.0176
  dc      0.0000
  dc     -0.0225
  dc      0.0000
  dc     -0.0286
  dc      0.0000
  dc     -0.0365
  dc      0.0000
  dc     -0.0470
  dc      0.0000
   dc    -0.0615
   dc     0.0000
   dc    -0.0836
   dc     0.0000
   dc    -0.1220
   dc     0.0000
   dc    -0.2090
   dc     0.0000
   dc    -0.6355
   dc          0
   dc     0.6355
   dc     0.0000
   dc     0.2090
   dc     0.0000
   dc     0.1220
   dc     0.0000
   dc     0.0836
   dc     0.0000
   dc     0.0615
   dc     0.0000
   dc     0.0470
   dc     0.0000
   dc     0.0365
   dc     0.0000
   dc     0.0286
   dc     0.0000
   dc     0.0225
   dc     0.0000
   dc     0.0176
   dc     0.0000
   dc     0.0136
   dc     0.0000
   dc     0.0105
   dc     0.0000
   dc     0.0079
   dc     0.0000
   dc     0.0059
   dc     0.0000
   dc     0.0043
   dc     0.0000
   dc     0.0030
   dc     0.0000
   dc     0.0021
   dc     0.0000
   dc     0.0013
   dc     0.0000
   dc     0.0008
   dc     0.0000
   dc     0.0006
   dc     0.0000










 start1:
                                                      ;filtr fir n



  move       #wspolczynniki,r0
  move       #0,r1
  do  #N+1,wsploop
  move       p:(r0)+,x0
  move       x0,y:(r1)+
wsploop:







           movep             #$260040,x:pctl         ; uaktywnij PLL i ustaw 50MHz

           movep             #$000201,x:rcs          ;uaktywnij SAI


           movep             #$000203,x:tcs          ;uaktywnij SAI






                           ;movep #$000101,x:brc     ;uaktywnij preskaler
                           ;    movep #$000c00,x:ipr
                           ;  ori   #$0c,mr   ;wylacz przerwania





          move              #0,r0                   ;poczatek bufora probek
          move              #0,r4                   ;pocz. buf. wsp.
          move              #N-1,m0                 ;arytm. mod N dla rej. adres
          move              m0,m4                   ;dotycz. obu buforow

          move              #$100,r3

          move              #$3,N3
          move              #$140,r2

          move              #$3,N2
          move              #$0ff,m3
          move              #$0ff,m2
          move              #N-1,m1

          move              #0,r1                   ;poczatek bufora probek
          move              #41,N1


          move              #$100,r5                   ;pocz. buf. wsp.
          move              #$0ff,m5                 ;arytm. mod N dla rej. adres
          move               #50,N5






;      do #128,przes
;      nop
;      move (r4)+
;      nop
;przes:



petla:
          nop
          jset    #rldf,x:rcs,odbierz_lewy

          nop
          jset    #rrdf,x:rcs,odbierz_prawy






          bset    #gdd3,x:gpior

          nop
          jmp     petla


odbierz_lewy:
  ;        bclr    #gdd3,x:gpior

          move              x:rx0,a



;          move #0.021,x1
;          move  y:(r5)+n5,a ;cosinus
;          mpy  x1,y0,b
;          neg b
;          add  b,a

          move              a,x:tx1


          nop
          move              a,x:(r0)                ;zapisz probke do pamieci
          clr     a         x:(r0)+,x0  y:(r4)+,y0
          do      #N-1,splot

          mac     x0,y0,a   x:(r0)+,x0  y:(r4)+,y0
splot:
          macr    x0,y0,a   (r0)-
          nop

          move              a,x0                    ;xh
 ;         move              a,x:tx1
          move                          y:(r2)+N2,y0 ;cosinus
          nop
;          move              y0,x:tx1

          clr     b
          nop
          mac     x0,y0,b

          move              r0,r1
          nop
          move              x:(r1+N),x0             ;xd
          nop

;           move #0.99,y1
 ;          mpy  x0,y1,a
 ;         move a,x0
 ;         nop

          move                          y:(r3)+N3,y0 ;sin
;          move              y0,x:tx1
    neg b
          move              b,a
          nop
          macr    x0,y0,a

;          move #0.021,x1
;          move  y:(r2),y0 ;cosinus
;          mpy  x1,y0,b
;          neg b
;          add  b,a

          nop
          move              a,x:tx0

          nop
          jmp     petla


odbierz_prawy:
          bclr    #gdd3,x:gpior

          move              x:rx0,a

          nop
                                                    ;move r0,r1
                                                    ;nop
         move              a,x:tx1                                                        ;move x:(r1+N),x0    ;xd
                                                    ;nop
                                                    ;
                                                    ;move y:(r3)+N3,y0   ;sinus
                                                    ;move b,a
                                                    ; nop
                                                    ; macr x0,y0,a
                                                    ; nop
          move              a,x:tx0


          nop
          jmp     petla







;start2:

;    move x:rx0,a
                                                    ; abs a
;    asl a
                                                    ;move a,x:tx0


                                                    ; jmp petla

;start3:
;    nop
;    bset #gdd3,x:gpior
;    nop
                                                    ; do #1,petla2
                                                    ; do #1,petla1

;    nop




;petla1:
;    nop
;petla2:
;

;    bclr #gdd3,x:gpior
  ; do #1,petla3





                                                            ; do #1,petla4

        ;    nop

        ;petla4:
        ;   nop
        ;petla3:
                                                            ; rti

        ;    jmp start2
        ;     jmp petla
















































