chiark / gitweb /
new arrangements including points; about to hack for qq test
authorian <ian>
Tue, 6 Dec 2005 23:31:06 +0000 (23:31 +0000)
committerian <ian>
Tue, 6 Dec 2005 23:31:06 +0000 (23:31 +0000)
15 files changed:
detpic/Makefile
detpic/common.inc
detpic/detect.asm
detpic/detect.inc
detpic/final.inc
detpic/misc.asm
detpic/morse.messages
detpic/points.asm
detpic/program.asm [new file with mode: 0644]
detpic/program.fin [new file with mode: 0644]
detpic/reverse.asm
detpic/reverse.fin [new file with mode: 0644]
detpic/slave.asm
detpic/test-sofar.asm
detpic/variables.asm

index 26901368aca08ae7f37045f2db74ca75ed7b216b..e33439ce5e17e0e0740c2cce15bf2d653528c8cc 100644 (file)
@@ -2,12 +2,12 @@
 CEBPIC=                ../cebpic/
 PICNOS=                0 1 2
 
-PROGRAMS=              test-sofar
-OBJS_test-sofar=       vectors.o panic.o routines-led.o i2clib.o       \
+PROGRAMS=              program
+OBJS_program=          vectors.o panic.o routines-led.o i2clib.o       \
                        misc.o slave.o detect.o variables.o points.o    \
-                       syncwrite.o
-XCODEN_test-sofar=     morse
-XCODE1_test-sofar=     blank2 ours+pindata
+                       syncwrite.o reverse.o test-sofar.o
+XCODEN_program=        morse
+XCODE1_program=        blank2 ours+pindata
 
 INCLUDES=      common.inc                      \
                final.inc                       \
@@ -20,7 +20,9 @@ INCLUDES=     common.inc                      \
                vectors.fin                     \
                pindata.inc                     \
                detect.inc                      \
-               points.fin
+               points.fin                      \
+               program.fin                     \
+               reverse.fin
 
 VARSFILES=     variables
 
index 10cfe0a25379b11b040f1acc7c195aa30e70f2e5..5850b91b442011a0853462ba46d8e170eea66f85 100644 (file)
@@ -25,6 +25,7 @@ clock equ -1
 ;   BSR                        Not used                Not used
 ;   t                  Low ISR                 Low ISR
 ;   TBLPTR*,TABLAT     Low ISR                 Low ISR
+;   PROD*              Low ISR                 Low ISR
 ;   FSR0               Low ISR                 Low ISR
 ;   FSR1               Low ISR                 High ISR (detect[1])
 ;   FSR2               Low ISR                 High ISR (detect[1])
@@ -113,6 +114,9 @@ return_interrupt_low macro
 ;----------------------------------------
 ; For disabling all interrupts, to make a critical section:
 ; (for use from main program and Low ISR only)
+;
+;  GIEH                        modified appropriately
+;  everything else     preserved
 
 mask_int_high macro
        bc_f    INTCON,GIEH
@@ -125,6 +129,11 @@ unmask_int_high macro
 ;----------------------------------------
 ; For the fix specified in the silicon errata:
 ; silicon revision B4 issue 4
+;
+;                      Before          After
+;  TABLAT              any             data from flash
+;  TBLPTR*             correct         incremented/decremented
+;  everything else     any             preserved
 
 tblrd_postinc_fixup macro
        tblrd   *+
@@ -140,7 +149,13 @@ tblrd_postdec_fixup macro
 ; For setting up TBLPTR according to the picno
 
 load_perpic_tblptr macro flash_map_base, perpic_entry_size
-       movlw   perpic_entry_size
+;
+;                      Before          After
+;  TBLPTR*             any             set
+;  W, STATUS, PROD*    any             undefined
+;  everything else     any             preserved
+;
+       mov_lw  perpic_entry_size
        mul_wf  picno
 
        mov_lw  flash_map_base & 0xff
@@ -177,6 +192,22 @@ p0_booster_dirn            equ     0c
 p0_booster_pwm         equ     1c
  radix dec
 
+;                      
+;  LAT*                        may be subject to read-modify-write, see below
+;  TRIS*               may be subject to read-modify-write, see below
+;  PORT*               may be read, see below
+;  everything else     untouched
+;
+;                      LAT*<bit>       TRIS*<bit>      PORT*
+;  pin_z               untouched       set             untouched
+;  pin_h               set             cleared         untouched
+;  pin_l               cleared         cleared         untouched
+;  pin_nz              untouched       cleared         untouched
+;  pin_vh              set             untouched       untouched
+;  pin_vl              cleared         untouched       untouched
+;  pin_ifh             untouched       untouched       read
+;  pin_ifl             untouched       untouched       read
+
 pin_z  macro   pinspec
        bs_f    TRISA + (TRISB-TRISA)*((pinspec-0xa) & 15), pinspec >> 4
        endm
index b9d9bcf88b0685e9181a43542a88d47dd594e3c5..3c77ed56882ebd62b82fb793f38734de4a78f9da 100644 (file)
@@ -109,46 +109,38 @@ message_buffer_end
        code
 
 ;----------
-det_common_init
+detect_local_init
        mov_lw  b'111'  ; turn off comparator, or we can't use pins
        mov_wf  CMCON   ;   RD0-RD4 as digital inputs
        mov_lw  b'0110' ; turn off A/D except perhaps for pin
        ior_wff ADCON1  ;   AN0 ie SPARE ie RA0 (same reason as above)
-       return
 
-;----------
-det_slave_init
-       rcall   det_common_init
+       ; compute buf0_startval
+       clr_w
+       bt_f_if0 idloc1,idloc1_boarddet
+       mov_lw  0x14 ; see under reversers, below
+       mov_wf  buf0_startval
+
        set_f   scana
        set_f   scanb
        set_f   scanc
        set_f   scand
        set_f   scane
+       mov_ff  buf0_startval, buf0
 
-       clr_w
-
-       bt_f_if0 idloc1,idloc1_boarddet
-       mov_lw  0x14 ; see under reversers, below
-
-       mov_wf  buf0_startval
+       return
 
+;----------
+detect_slave_init
        mov_lfsr outbuf, 2
        clr_f   outmsg_end
 
        goto    reset_message_buffer
 
-;----------
-message_for_master
-; Either transmits the message to the master, or if we are the master,
-; handles it as an incoming message from the notional `slave 0'.
-;  W           message         unchanged
-;  GIEH                set             set
-       bt_f_if1 idloc1,idloc1_master
-       goto    loopback_read_byte
-
-;.....
 ;----------------------------------------
 slave_add_short_message
+; Queues a message byte for transmission to the master.
+; It will be transmitted as an extra message byte, when we are polled.
 ;  W           message         unchanged
 ;  GIEH                set             set
        mask_int_high
@@ -307,12 +299,12 @@ msg_copy_loop
        bra_n   msg_copy_loop
 
        mov_ff  FSR2L, outmsg_end
+       mov_ff  buf0_startval, buf0
 
 reset_message_buffer
 ;  FSR1/buf0/message_buffer    any             set to empty
 ;  may be called from High ISR or during init
        mov_lfsr message_buffer, 1
-       mov_ff  buf0_startval, buf0
        clr_f   INDF1
        return
 
index fc56c0de97ade1483990dab189471b7e868b4e15..0b84d60d7f4608d8b8439d10cb0e97b19d29a108 100644 (file)
@@ -1,4 +1,5 @@
- extern det_slave_init
- extern message_for_master
+ extern detect_local_init
+ extern detect_slave_init
+ extern slave_add_short_message
  extern backgroundloop_reversers
  extern backgroundloop_detectors
index 325852dd697bac6a0e1c3ecbdcfeb4315f2a9046..66e74ec09fba62e91429ca21eec8e73a97f1b3b7 100644 (file)
@@ -1,5 +1,6 @@
- extern slave
- extern loopback_read_byte
+ extern test_sofar_slave_startup_hook
+ extern trackpower_decide
+ extern serial_interrupt
 
  include vectors.fin
  include i2clib.inc
@@ -10,5 +11,7 @@
  include variables+vars.fin
  include detect.inc
  include ../iwjpictest/syncwrite.inc
+ include reverse.fin
+ include program.fin
 
        end
index fededfcc8e80fb115bab8c0c6317b59eaa5c136f..255f7db11771e310caed8796b6063ca8a313a454 100644 (file)
@@ -49,7 +49,4 @@ init_bitnum2bit_loop
        bra_nn  init_bitnum2bit_loop
        return
 
-;======================================================================
-; MASTER/SLAVE deviations
-
  include final.inc
index 256494dfb2a8e57f072b9a52c84121ea51283abc..43c499e80168e90354371322e5ed726c5bdb8595 100644 (file)
@@ -31,8 +31,10 @@ TI5                          ; for iwj
 X      test-sofar:ch           ; bad character received from host
 
 # Unimplemented things
-UP             ; unimplemented point timer setting
-UL             ; unimplemented master loopback read
+UP
+UL
+UM
+UE
 
 ZM     i2clib:st,:sspstat,:sspcon1,:sspcon2 ; for testing
 ZS     i2clib:st,:sspstat,:sspcon1,:st_orig ; for testing
index 1e0e78f7596d87db1f38223c600cda465e519187..1514b6ac29c5eaebc38487f7b7e39b6d0b768daf 100644 (file)
@@ -11,7 +11,7 @@
 ;      pointmsg        undefined       message from master
 
 ptix2bitlat equ 0x300
- udata ptix2bitlat
+ptix2bitlat_section udata ptix2bitlat
  res maxpoint * 2      ; bit and LAT*
                        ; for unused point, 0x00 and 0x00
 
diff --git a/detpic/program.asm b/detpic/program.asm
new file mode 100644 (file)
index 0000000..44b7037
--- /dev/null
@@ -0,0 +1,45 @@
+;======================================================================
+; MAIN PROGRAM AND GLUE
+
+ include common.inc
+ code
+
+;----------
+vector_reset
+       clr_f   INTCON
+       bs_f    RCON, IPEN      ; interrupt priorities
+
+       call    idlocs_init
+
+       tst_f_ifnz picno
+       goto    slave
+       bra     master
+
+;----------
+master_interrupt_low
+       enter_interrupt_low
+       call    i2cm_interrupt
+       call    serial_interrupt
+       return_interrupt_low
+
+;======================================================================
+; MASTER/SLAVE deviations
+
+;----------
+message_for_master
+; Either transmits the message to the master, or if we are the master,
+; handles it as an incoming message from the notional `slave 0'.
+;  W           message         unchanged
+;  GIEH                set             set
+       bt_f_if1 idloc1,idloc1_master
+       goto    loopback_read_byte
+       goto    slave_add_short_message
+
+;======================================================================
+; UNIMPLEMENTED STUFF
+
+;----------
+loopback_read_byte
+       panic   morse_UL
+
+ include final.inc
diff --git a/detpic/program.fin b/detpic/program.fin
new file mode 100644 (file)
index 0000000..a45ed10
--- /dev/null
@@ -0,0 +1,3 @@
+ extern slave
+ extern master
+ extern message_for_master
index 4f055eba31ac2276c6f1499d668ca128687aaf3e..894b36bdf6bf15fde81536254211864c66f9f11f 100644 (file)
@@ -1,6 +1,8 @@
 ;======================================================================
 ; REVERSERS
 
+ include common.inc
+
 ;----------------------------------------
 ; LOCAL REVERSERS - Variables
 
@@ -11,12 +13,6 @@ maske                                res     1
 ;----------------------------------------
 ; MASTER - Access bank variables and other sections
 
-board0                         res     1
-gather                         res     1
-
-polarities_waiting             res     1
-       ; no of 11... entries in reversers_commanded_buffer
-
  udata
 polarities_commanded_buffer    res     maxpic+1
        ; Each byte is:
@@ -75,10 +71,10 @@ polarity_local_init
        rcall   polarity_local_do
 
        com_fw  maska
-       and_wf  TRISA
+       and_wff TRISA
 
        com_fw  maske
-       and_wf  TRISE
+       and_wff TRISE
 
        return
 
@@ -106,28 +102,35 @@ polarity_master_do
 ;              is a for LSb in message to PIC, b for next bit,
 ;              and so on until f for bit 5.  (See polarity_do_here, below.)
 ;
-       mov_lfsr message_buffer_start,0
-       mov_lfsr reversers_commanded_buffer,1
+; we accumulate (`gather') the `g' bits in t.
+;
+
+ panic morse_UM
+;;     mov_lfsr message_buffer_start,0
+
+
+       mov_lfsr polarities_commanded_buffer,1
        mov_fw  POSTINC0        ; W =           10010RRR
-       mov_wf  gather          ; gather =      10010ggg
-       xor_lw  0b10001000      ; gather =      00011ggg
-loop ; exit from this loop is done by board popping and returning
+       mov_wf  t               ; t =           10010ggg
+       xor_lw  b'10001000'     ; t =           00011ggg
+loop ; Exit from this loop is done by board popping, doing some
+     ; final stuff, and returning.   See board_next_none, below.
        rrc_fw  INDF0           ; W =           ?Mhhhhhh  C = g
-       rlc_f   gather          ; gather =      0*11g+    C = ?
+       rlc_f   t               ; t =           0*11g+    C = ?
        bra_nn  if_not_gathered
-       ;                       ; gather =      11gggggg
-       mov_fw  gather
+       ;                       ; t =           11gggggg
+       mov_fw  t
        rcall   board
-       mov_lw  0b00000011      ; W =           00000011
-       mov_wf  gather          ; gather =      00000011
+       mov_lw  b'000000011'    ; W =           00000011
+       mov_wf  t               ; t =           00000011
 if_not_gathered                        ; *INDF0 =      Mhhhhhhg
        rr_fw   INDF0           ; W =           gMhhhhhh
-       or_lw   0b11000000      ; W =           11hhhhhh
+       ior_lw  b'011000000'    ; W =           11hhhhhh
        rcall   board
        bt_f_if1 POSTINC0,7     ; *POSTINC0 :   M.......
        bra     loop
        ; otherwise:
-       panic   morse_PS
+       panic   morse_RS
 
 ;----------
 board
@@ -154,6 +157,18 @@ board_next_none
        bra     board_next_none_more_message
 ;...
 ; now we're exiting from the loop in when_reverse_message_found
-       pop
-       return
+       pop      ; that disposes of the call to `board'
+
+       goto    trackpower_decide
+       ; that will turn it off, since polarities_waiting is nonzero
+
+;----------
+board_next_none_more_message
+       panic   morse_RL
 
+;----------
+trackpower_decide
+       panic   morse_UE
+
+;======================================================================
+ include final.inc
diff --git a/detpic/reverse.fin b/detpic/reverse.fin
new file mode 100644 (file)
index 0000000..0ad7380
--- /dev/null
@@ -0,0 +1 @@
+ extern polarity_local_init
index 3b7d6c8151324a6e2eaa8155878e245be9ee5d6e..c356cd06462332e620bd0a3bdf0a2bd00b340f97 100644 (file)
 slave
        mov_fw  picno
        call    i2cs_init
+       call    test_sofar_slave_startup_hook
        call    bitnum2bit_init
        call    points_local_init
-       call    det_slave_init
+       call    polarity_local_init
+       call    detect_local_init
+       call    detect_slave_init
 
        mov_lw  (1<<GIEH) | (1<<GIEL)
        mov_wf  INTCON
index 18ffa1af784b6fb569630ca50579f2711142d680..1c4178594cf42276d01c90aea6c2a83230ee9515 100644 (file)
@@ -82,24 +82,6 @@ delay_countslow              res     1
 
        code
 
-;----------
-vector_reset
-       clr_f   INTCON
-       bs_f    RCON, IPEN      ; interrupt priorities
-
-       call    idlocs_init
-
-       tst_f_ifnz picno
-       goto    slave
-       bra     master
-
-;----------
-master_interrupt_low
-       enter_interrupt_low
-       call    i2cm_interrupt
-       call    serial_interrupt
-       return_interrupt_low
-
 ;----------
 master_interrupt_high
        panic   morse_IP
@@ -136,10 +118,6 @@ m_infinite
        call    led_green
        bra     m_infinite
 
-;----------
-loopback_read_byte
-       panic   morse_UL
-
 ;----------
 serialu_read_char
 ;      W       character read          any
@@ -260,6 +238,76 @@ panic_kill_hook
        pin_l   p0_cdu_enable
        return
 
+;----------------------------------------------------------------------
+; SLAVE  TESTING VERSION
+; buffer is at 0x100..0x107
+; FSR0 is write pointer
+; FSR1 is read pointer
+
+;----------
+test_sofar_slave_startup_hook
+       mov_fw  picno
+       mov_wf  t
+;...
+s_shownum_loop
+       call    s_delay
+       call    led_red
+       call    s_delay
+       call    led_black
+
+       dec_f_ifnz t
+       bra     s_shownum_loop
+; Exit loop:
+
+       mov_lw  0x07
+       mov_wf  qqTRISE
+       set_f   qqTRISD
+       set_f   qqTRISC
+       set_f   qqTRISB
+       mov_lw  0x7f
+       mov_wf  qqTRISA
+
+       mov_lw  0x5
+       mov_wf  qqLATE
+       mov_lw  0x55
+       mov_wf  qqLATD
+       mov_wf  qqLATC
+       mov_wf  qqLATB
+       mov_wf  qqLATA
+
+       mov_lw  0x1a
+       mov_wf  qqTRISA-1
+       mov_lw  0x2b
+       mov_wf  qqTRISE+1
+       mov_lw  0x3c
+       mov_wf  qqLATE+1
+       mov_lw  0x4d
+       mov_wf  test_sofar_slave_buf-1
+       mov_wf  test_sofar_slave_buf-2
+       mov_wf  test_sofar_slave_buf-3
+       mov_wf  test_sofar_slave_buf-4
+
+;...
+;----------
+s_buffer_reset
+       mov_lfsr test_sofar_slave_buf, 0
+       mov_lfsr test_sofar_slave_buf, 1
+       return
+
+;----------
+QQ_i2csu_read_begin
+       rcall   led_green
+QQ_i2csu_read_another
+       mov_fw  POSTINC1
+       bc_f    FSR1L, test_sofar_s_bufbit
+       goto    i2cs_read_data
+
+
+;----------
+s_panic_req
+       clr_f   ch
+       panic   morse_X
+
 ;======================================================================
 
 m_delay4 rcall m_delay2
index 15d7728ebb718e4b18b66f5dd706f2688ebe9413..9a5d986eb198f43f66e4aac2ad61718c0ef87827 100644 (file)
@@ -8,8 +8,11 @@ idloc1_boarddet        equ     6
 t              res     1       ; general temporary
 outmsg_end     res     1       ; first empty byte in outbuf
 
-isr_low_save_w         res     1
-isr_low_save_status    res     1
+isr_low_save_w         res     1 ; see {enter,return}_interrupt_low
+isr_low_save_status    res     1 ;  in common.inc
+
+polarities_waiting     res     1
+ ; no of 11... entries in polarities_commanded_buffer, see reversers.asm
 
 outbuf_section udata 0x200
 outbuf_szln2   equ     7
@@ -19,6 +22,24 @@ outbuf               res     outbuf_size
 bitnum2bit_section udata 0x0f8
 bitnum2bit     res     8       ; bitnum2bit[x] = 1<<x
 
+test_sofar_slave_buf_section udata 0x180
+
+test_sofar_s_bufbit equ 4 ; ln2(buffer size)
+test_sofar_slave_buf
+ res 1
+qqTRISA res 1
+qqTRISB res 1
+qqTRISC res 1
+qqTRISD res 1
+qqTRISE res 1
+ res 1
+qqLATA res 1
+qqLATB res 1
+qqLATC res 1
+qqLATD res 1
+qqLATE res 1
+ res 4
+
  include final.inc
 
 ;======================================================================