

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
tlde equ 14
trde equ 15

N equ 30           ;rzad filtru Hilberta


  org p:$0
  jmp start1

 ; org p:$2    ;stack error
 ; rti

 ;  org p:$4   ;trace
 ;  rti


 ;  org p:$6   ;SWI
 ;  rti

 ;  org p:$8       ;IRQa
   ; jmp wyjatek
 ;  rti

 ;  org p:$0a      ;IRQb
   ; jmp wyjatek
 ;  rti

 ;  org p:$10      ;SAI L TX
   ; jmp wyjatek
 ;  rti

 ;  org p:$12      ;SAI R TX
   ; jmp wyjatek
 ;  rti


 ; org p:$14       ;SAI TX Exception
 ; jmp wyjatek
 ;  rti

  org p:$16         ;SAI L RX
  jmp odbierz_lewy

  org p:$18          ;SAI R RX
  jmp odbierz_prawy

  org p:$1a         ;SAI RX Exception
 ; jmp wyjatek
   rti


 ; org p:$4a
  ;jmp wyjatek
 ; rti

  org p:$7f
start1:
  ;filtr fir na


  move      #-0.0941,a
  move a,y:0
  move      #0.0218,a
  move a,y:1
  move      #-0.0650,a
  move a,y:2
  move      #0.0320,a
  move a,y:3
  move      #-0.0844,a
  move a,y:4
  move      #0.0394,a
  move a,y:5
  move      #-0.1040,a
  move a,y:6
  move      #0.0421,a
  move a,y:7
  move      #-0.1257,a
  move a,y:8
  move      #0.0389,a
  move a,y:9
  move      #-0.1578,a
  move a,y:10
  move      #0.0300,a
  move a,y:11
  move      #-0.2330,a
  move a,y:12
  move      #0.0163,a
  move a,y:13
  move      #-0.6440,a
  move a,y:14
  move      #0,a
  move a,y:15
  move      #0.6440,a
  move a,y:16
  move      #-0.0163,a
  move a,y:17
  move      #0.2330,a
  move a,y:18
  move      #-0.0300,a
  move a,y:19
  move      #0.1578,a
  move a,y:20
  move      #-0.0389,a
  move a,y:21
  move      #0.1257,a
  move a,y:22
  move      #-0.0421,a
  move a,y:23
  move      #0.1040,a
  move a,y:24
  move      #-0.0394,a
  move a,y:25
  move      #0.0844,a
  move a,y:26
  move      #-0.0320,a
  move a,y:27
  move      #0.0650,a
  move a,y:28
  move      #-0.0218,a
  move a,y:29
  move      #0.0941,a
  move a,y:30








    movep #$260036,x:pctl    ; uaktywnij PLL i ustaw 50MHz
    movep #$000a01,x:rcs     ;uaktywnij SAI RX

    movep #$000201,x:tcs     ;uaktywnij SAI TX
  ;  movep #$000101,x:brc     ;uaktywnij preskaler


    movep #$000c00,x:ipr
    andi   #$0fc,mr   ;wlacz 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 #$1,N3
      move #$139,r2
      move #$1,N2
      move #$0ff,m3
      move #$0ff,m2

      move #0,r1      ;poczatek bufora probek
      move #15,N1
      move #0,r5      ;pocz. buf. wsp.
      move #N-1,m1    ;arytm. mod N dla rej. adres
      move m1,m5      ;dotycz. obu buforow





petla_idle:
    nop
    bclr #gdd3,x:gpior
    nop
    jmp petla_idle










   wyjatek:
  bclr #gdd3,x:gpior
  bset #gdd3,x:gpior

   rti




odbierz_lewy:

    move x:rx0,a
;    bset #gdd3,x:gpior
;    bclr #gdd3,x:gpior


;    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
;    nop
;    move y:(r2)+N2,y0    ; cosinus
;    clr b
;    nop
;    mac  x0,y0,b

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

;    move y:(r3)+N3,y0   ;sinus

;    move b,a
;    nop
;    macr x0,y0,a
;
    nop

    ;;;;
  ;  move y0,a
    nop

    ;;;;
czekaj_l:
;   jclr #tlde,x:tcs,czekaj_l

    move a,x:tx0
    nop
  ;  bclr #gdd3,x:gpior


    rti


odbierz_prawy:
    nop
 ;   bclr #gdd3,x:gpior
 ;   nop
    move x:rx0,a
 ;   nop
  ;  move r0,r1
  ;  nop
  ;  move x:(r1+N),x0    ;xd
  ;  nop
  ;
  ;  move y:(r3)+N3,y0   ;sinus
  ;  move b,a
 ;   nop
 ;   macr x0,y0,a
 ;   nop
    nop
czekaj_r:
 ;  jclr #trde,x:tcs,czekaj_r
;   nop
   move a,x:tx0
 ;  nop
   rti






