From: ian Date: Wed, 30 Nov 2005 22:17:40 +0000 (+0000) Subject: new slave stuff with hex and final checks before testing X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=4f5f23e802b2a7d62ef8e659d16ed9b4d1584276;p=trains.git new slave stuff with hex and final checks before testing --- diff --git a/cebpic/manypics.make b/cebpic/manypics.make index 1c647eb..eda53a2 100644 --- a/cebpic/manypics.make +++ b/cebpic/manypics.make @@ -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 diff --git a/detpic/.cvsignore b/detpic/.cvsignore index 40a7350..f13daf9 100644 --- a/detpic/.cvsignore +++ b/detpic/.cvsignore @@ -11,3 +11,4 @@ gpsim.log idlocs*.asm morse+auto.inc ours-pindata.asm +syncwrite.asm diff --git a/detpic/Makefile b/detpic/Makefile index 2e5ee63..0679bc2 100644 --- a/detpic/Makefile +++ b/detpic/Makefile @@ -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 diff --git a/detpic/final.inc b/detpic/final.inc index d39f8ac..e7e771a 100644 --- a/detpic/final.inc +++ b/detpic/final.inc @@ -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 diff --git a/detpic/i2clib.asm b/detpic/i2clib.asm index 7467232..10f6f70 100644 --- a/detpic/i2clib.asm +++ b/detpic/i2clib.asm @@ -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 diff --git a/detpic/test-sofar.asm b/detpic/test-sofar.asm index 0ed4dee..07cbe66 100644 --- a/detpic/test-sofar.asm +++ b/detpic/test-sofar.asm @@ -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 @@ -69,13 +71,18 @@ 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 diff --git a/iwjpictest/Makefile b/iwjpictest/Makefile index 03caaa2..3b42caf 100644 --- a/iwjpictest/Makefile +++ b/iwjpictest/Makefile @@ -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) diff --git a/iwjpictest/harness.asm b/iwjpictest/harness.asm index e807c75..fea0f29 100644 --- a/iwjpictest/harness.asm +++ b/iwjpictest/harness.asm @@ -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 index 0000000..c921b2c --- /dev/null +++ b/iwjpictest/syncwrite.asm @@ -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 index 0000000..b34399d --- /dev/null +++ b/iwjpictest/syncwrite.inc @@ -0,0 +1,3 @@ + extern serial_write_char + extern serial_write_hex + extern serial_write_hex_digit diff --git a/pic.make b/pic.make index 1d4f1d3..fb3149d 100644 --- 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