chiark / gitweb /
new slave stuff with hex and final checks before testing
authorian <ian>
Wed, 30 Nov 2005 22:17:40 +0000 (22:17 +0000)
committerian <ian>
Wed, 30 Nov 2005 22:17:40 +0000 (22:17 +0000)
cebpic/manypics.make
detpic/.cvsignore
detpic/Makefile
detpic/final.inc
detpic/i2clib.asm
detpic/test-sofar.asm
iwjpictest/Makefile
iwjpictest/harness.asm
iwjpictest/syncwrite.asm [new file with mode: 0644]
iwjpictest/syncwrite.inc [new file with mode: 0644]
pic.make

index 1c647eb7aacbee9425d7e3493eed52904ae5b99b..eda53a299bb231b78851960a4d186243a6ad78f3 100644 (file)
@@ -57,7 +57,6 @@ blank0.asm blank2.asm blank4.asm blank6.asm: blank%.asm: $(CEBPIC)manypics.make
 TARGETS += $(foreach i, $(PICNOS), idlocs$i.hex noncode$i.hex)
 MORSE_INCLUDE ?= common.inc
 INCLUDES += ../iwjpictest/insn-aliases.inc morse+auto.inc
-MERGEHEX= $(CEBPIC)merge-hex $^ $o
 
 include ../common.make
 include ../pic.make
index 40a7350ecca412c9eca23501bbf0fb2240109311..f13daf98f3f6b7bcaa1c620752335321e45b018f 100644 (file)
@@ -11,3 +11,4 @@ gpsim.log
 idlocs*.asm
 morse+auto.inc
 ours-pindata.asm
+syncwrite.asm
index 2e5ee6343e50c17f4c60a97b9f3764af14de9d28..0679bc27532c2b86fb916208dce090d888587378 100644 (file)
@@ -4,7 +4,8 @@ PICNOS=         0 1 2
 
 PROGRAMS=              test-sofar
 OBJS_test-sofar=       vectors.o panic.o routines-led.o i2clib.o       \
-                       misc.o slave.o detect.o variables.o
+                       misc.o slave.o detect.o variables.o             \
+                       syncwrite.o
 XCODEN_test-sofar=     morse
 XCODE1_test-sofar=     blank2 blank6
 
@@ -23,4 +24,7 @@ VARSFILES=    variables
 
 include                $(CEBPIC)manypics.make
 
+syncwrite.asm: ../iwjpictest/syncwrite.asm
+               cp $< $@
+
 clean:         manypic-clean
index d39f8ac883840adb07c1aa164e551c3cccde34fe..e7e771a3a4af85648ffd148d97d4739978925373 100644 (file)
@@ -1,5 +1,3 @@
- extern serial_write_char
-
  extern slave
 
  include vectors.fin
@@ -9,5 +7,6 @@
  include misc.fin
  include variables+vars.fin
  include detect.inc
+ include ../iwjpictest/syncwrite.inc
 
        end
index 746723268e6a4b0ebf2432014bc01e0cec66acf6..10f6f70f5aa14966203b9357e6a50f93d9739273 100644 (file)
@@ -417,6 +417,9 @@ init_enable
 ;      set   clr   data? stop          start read? clr   full?
 ; (we don't usually mention SMP, CKE and UA below)
 
+; Labels of the form s_event_* are branches of the interrupt
+; handler and are supposed to finish with retfie_r.
+
 ; Some macros:
 
 chkvals_start macro what
@@ -484,6 +487,7 @@ s_event_reading
                bra_nz  s_event_reading_not_another
                call    i2csu_read_another
                                ; 24cy until 1st insn of i2csu_read_another
+s_event_reading_datanack
                retfie_r
 
 ;...
@@ -510,8 +514,7 @@ i2cs_read_data
                bra     improper_read_done_data
                bc_f    st, st_awaiting
                bs_f    st, st_reading
-s_event_reading_datanack
-               retfie_r
+               return
 
 ;========================================
 ; SLAVE - WRITING
@@ -552,11 +555,8 @@ s_event_writing
                mov_fw  SSPSTAT
                and_lw  0xc7 ; ?D_A, ?P; ?S
                xor_lw  0x80 ; SMP, !CKE, !R_W, !UA, !BF
-               bt_f_if1 STATUS, Z
+               bra_nz  s_event_bad
                retfie_r
-               ; no good
-
-               bra     s_event_bad
 
 ;----------
 s_event_writing_datarecv
index 0ed4dee5233e4d3ccd9cfeebc796ef1e76136a3a..07cbe66d5895a7137eca6d199f1b4146a1ae85d4 100644 (file)
@@ -42,6 +42,8 @@
 ;      0       set buffer pointer to start, clear that byte
 ;      other   append char to buffer, clear byte at buffer pointer
 ;      
+;      $       toggle hex mode for reading
+;
 ;  Output characters:
 ;      SPC     i2cmu_done
 ;      other   i2cmu_read_got_byte
 
        udata_acs
 
-t      res     1
-ch     res     1
+t              res     1
+ch             res     1
+mode           res     1
+mode_readhex   equ     0
 
 delay_countfast                res     1
 delay_countmedium      res     1
 delay_countslow                res     1
 
+save_w         res     1
+save_status    res     1
+
        code
 
 ;----------
@@ -90,9 +97,14 @@ vector_reset
 
 ;----------
 master_interrupt_low
+       mov_ff  STATUS,save_status
+       mov_wf  save_w
+       ; we assume that none of the ISRs use BSR
        call    i2cm_interrupt
        call    serial_interrupt
-       retfie_r
+       mov_fw  save_w
+       mov_ff  save_status,STATUS
+       retfie
 
 ;----------
 master_interrupt_high
@@ -106,6 +118,8 @@ master_interrupt_high
 ; FSR1 permanently points to start of buffer
 
 master
+       clr_f   mode
+
        call    serial_setup
        call    i2cm_init
        call    led_green
@@ -209,7 +223,9 @@ m_buffer_fix_fsr0h
 i2cmu_done
        mov_lw  ' '
 i2cmu_read_got_byte
+       bt_f_if0 mode,mode_readhex
        bra     serial_write_char
+       bra     serial_write_hex
 
 ;----------
 i2cmu_write_next_byte
@@ -266,15 +282,6 @@ serial_read_if_error
        rcall           serial_receive_reset
        return
 
-;----------------------------------------
-serial_write_char
-; W            character       undefined
-serial_write_char_loop
-       bt_f_if0        PIR1, TXIF
-       bra             serial_write_char_loop
-       mov_wf          TXREG
-       return
-
  include final.inc
 
        end
index 03caaa26d3f6cd5424049621273222e096b8483a..3b42caf8af6d9656ca297eacfa4ba44f4b813db8 100644 (file)
@@ -6,23 +6,29 @@ INSN_TARGETS= insn-aliases.inc \
 
 PROGRAMS=      flasher copybits serialloop harness
 
-INCLUDES=      insn-aliases.inc  onecopybit.inc  test.inc  clockvaries.inc
+INCLUDES=      insn-aliases.inc  onecopybit.inc  test.inc  clockvaries.inc \
+               ../iwjpictest/syncwrite.inc
+
+CEBPIC=../cebpic/
 
 include ../common.make
 
 PROGRAM_HEXES= $(addsuffix .hex, $(PROGRAMS)) \
-               $(addsuffix -withcfg.hex, $(PROGRAMS))
+               $(addsuffix +withcfg.hex, $(PROGRAMS))
 
 all:           $(TARGETS) $(PROGRAM_HEXES)
 
 include ../pic.make
 
-%-withcfg.hex: %.o config.o $(LIBS) $(DEFLIBS)
-               $(LINK)
+%+withcfg.hex: %.hex config.hex
+               $(MERGEHEX)
 
 %.hex:         %.o $(LIBS) $(DEFLIBS)
                $(LINK)
 
+harness.hex:   harness.o syncwrite.o $(LIBS)
+               $(LINK)
+
 clean:         pic-clean
                rm -f $(INSN_TARGETS)
 
index e807c75e0298261629ed48a99fb5f1d9cfba4c2e..fea0f29b8efb2149b6eea8f9417ea83d5668f37a 100644 (file)
@@ -66,21 +66,30 @@ s           equ     FSR1L
 sh             equ     FSR1H
 star_s         equ     INDF1
 
-perpicled_bit  equ     2
+ udata_acs
+ res 2 ; skip 0 and 1
+perpicled_bit  res 1
 
-e              equ     0x30
-t              equ     0x31
-b              equ     0x32
-f              equ     0x33
+sec_etbf udata_acs 0x30
+e              res 1
+t              res 1
+b              res 1
+f              res 1
 
-hex_temp       equ     0x38
-original_op    equ     0x39
-value_temp     equ     0x3a
+sec_temps udata_acs 0x38
+hex_temp       res 1
+original_op    res 1
+value_temp     res 1
 
 f_printset_bit equ     7
 
-test_loc_a5    equ     0x40
-test_loc_5a    equ     0x42
+sec_a5 udata_acs 0x40
+test_loc_a5    res 1
+
+sec_5a udata_acs 0x42
+test_loc_5a    res 1
+
+ code
 
 ;----------------------------------------
 serial_literal macro char
@@ -90,8 +99,6 @@ serial_literal macro char
        rcall           serial_write_char
        endm
 
-       code
-
 start
        rcall           led_green
        rcall           serial_setup
@@ -449,47 +456,5 @@ serial_read_if_error
        rcall           serial_receive_reset
        bra             serial_read_char_loop
 
-;----------------------------------------
-serial_write_char
-; W            character       undefined
-serial_write_char_loop
-       bt_f_if0        PIR1, TXIF
-       bra             serial_write_char_loop
-       mov_wf          TXREG
-       return
-
-;----------------------------------------
-serial_write_hex
-;      transmits W in hex through serial port
-;              Before          After
-; W            value           undefined
-; hex_temp     undefined       undefined
-       mov_wf          hex_temp
-       rcall           serial_write_hex_1digit_for_both
-       rcall           serial_write_hex_1digit_for_both
-       return
-
-;--------------------
-serial_write_hex_1digit_for_both
-;      transmits top nybble of hex_temp in hex
-;      through serial port, as above, and swaps nybbles
-;              Before          After
-; W            any             undefined
-; hex_temp     BBBBaaaa        aaaaBBBB        (BBBB was sent)
-       swap_f  hex_temp
-       mov_fw  hex_temp
-;...
-;--------------------
-serial_write_hex_digit
-;      transmits bottom nybble of W in hex
-; W            ????VVVV        undefined
-       and_lw  0x0f
-       sub_lw  10
-       sub_lw  0
-       bra_n   serial_write_hex_digit_ifnot_ge10
-       add_lw  'a'-('0'+10)
-serial_write_hex_digit_ifnot_ge10
-       add_lw  '0'+10
-       bra     serial_write_char
-
-       end
+ include syncwrite.inc
+ end
diff --git a/iwjpictest/syncwrite.asm b/iwjpictest/syncwrite.asm
new file mode 100644 (file)
index 0000000..c921b2c
--- /dev/null
@@ -0,0 +1,59 @@
+;======================================================================
+;
+; these routines all use serial_write_char which writes
+; bytes to the serial port synchronously
+
+       include         /usr/share/gputils/header/p18f458.inc
+       radix           dec
+       include         ../iwjpictest/insn-aliases.inc
+
+ udata_acs
+serial_hex_temp res 1
+
+ code
+
+;----------------------------------------
+serial_write_char
+; W            character       undefined
+serial_write_char_loop
+       bt_f_if0        PIR1, TXIF
+       bra             serial_write_char_loop
+       mov_wf          TXREG
+       return
+
+;----------------------------------------
+serial_write_hex
+;      transmits W in hex through serial port, using serial_write_char
+;                      Before          After
+; W                    value           undefined
+; serial_hex_temp      undefined       undefined
+       mov_wf          serial_hex_temp
+       rcall           serial_write_hex_1digit_for_both
+       rcall           serial_write_hex_1digit_for_both
+       return
+
+;--------------------
+serial_write_hex_1digit_for_both
+;      transmits top nybble of serial_hex_temp in hex
+;      through serial port, as above, and swaps nybbles
+;              Before          After
+; W                    any             undefined
+; serial_hex_temp      BBBBaaaa        aaaaBBBB        (BBBB was sent)
+       swap_f  serial_hex_temp
+       mov_fw  serial_hex_temp
+;...
+;--------------------
+serial_write_hex_digit
+;      transmits bottom nybble of W in hex
+; W            ????VVVV        undefined
+       and_lw  0x0f
+       sub_lw  10
+       sub_lw  0
+       bra_n   serial_write_hex_digit_ifnot_ge10
+       add_lw  'a'-('0'+10)
+serial_write_hex_digit_ifnot_ge10
+       add_lw  '0'+10
+       bra     serial_write_char
+
+ include ../iwjpictest/syncwrite.inc
+ end
diff --git a/iwjpictest/syncwrite.inc b/iwjpictest/syncwrite.inc
new file mode 100644 (file)
index 0000000..b34399d
--- /dev/null
@@ -0,0 +1,3 @@
+ extern serial_write_char
+ extern serial_write_hex
+ extern serial_write_hex_digit
index 1d4f1d3a2e4708ec32ff24f8d16c684ed2ea8fed..fb3149d4914e9e18710ac38f05f04a6180c391b0 100644 (file)
--- a/pic.make
+++ b/pic.make
@@ -19,10 +19,11 @@ ASFLAGS=    -Dmclock=20000 -Dsclock=5000
 
 LINK=          gplink -m -o $@ $^
 ASSEMBLE=      gpasm -p 18f458 $(ASFLAGS)
+MERGEHEX=      $(CEBPIC)merge-hex $^ $o
+DOASSEMBLE=    $(ASSEMBLE) -c $< && mv $*.lst $*-asm.lst
 
 %.o:           %.asm $(INCLUDES)
-               $(ASSEMBLE) -c $<
-               mv $*.lst $*-asm.lst
+               $(DOASSEMBLE)
 
 .PRECIOUS:     %.o