From 4702d2c917c0edd1c1e6dcd2ad370dca76cecfaf Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 4 Dec 2005 23:26:35 +0000 Subject: [PATCH] points wip --- cebpic/morse.messages | 2 + detpic/common.inc | 2 +- detpic/detect.asm | 1 + detpic/misc.asm | 9 ++++ detpic/morse.messages | 9 +++- detpic/pindata.inc | 5 ++ detpic/points.asm | 118 ++++++++++++++++++++++++++++++++++++++++++ detpic/reverse.asm | 2 +- detpic/slave.asm | 5 +- detpic/test-sofar.asm | 1 + 10 files changed, 148 insertions(+), 6 deletions(-) diff --git a/cebpic/morse.messages b/cebpic/morse.messages index 0dd18ef..f5b1dbc 100644 --- a/cebpic/morse.messages +++ b/cebpic/morse.messages @@ -15,6 +15,8 @@ # buffer space somewhere so that each one is read once and that value # remembered. +UP ; unimplemented point timer setting + # Main message listing. Kept sorted by morse for easy reference. IH INTCON,INTCON3,PIR1,PIR2,PIR3 ; Interrupt source not found (high pri.) IL INTCON,INTCON3,PIR1,PIR2,PIR3 ; Interrupt source not found (low pri.) diff --git a/detpic/common.inc b/detpic/common.inc index 21409b7..ebf3de5 100644 --- a/detpic/common.inc +++ b/detpic/common.inc @@ -67,7 +67,7 @@ clock equ -1 ; Timer 2 - - ; Timer 1 1ms tick, int. low 1ms tick, int. low ; CCP1 1ms tick, int. low 1ms tick, int. low -; Timer 3 - - +; Timer 3 point fire timer point fire timer ; ECCP - - ;---------------------------------------------------------------------- diff --git a/detpic/detect.asm b/detpic/detect.asm index 72cdad1..7abdf25 100644 --- a/detpic/detect.asm +++ b/detpic/detect.asm @@ -49,6 +49,7 @@ ; Master may also write to slave. Every written byte is independent: ; ; 11RRRRRR Set reverse to RRRRRR, see reverse.asm +; 100PPPPP Fire point PPPPP ;====================================================================== ; variables and memory organisation diff --git a/detpic/misc.asm b/detpic/misc.asm index d42c306..5eeca03 100644 --- a/detpic/misc.asm +++ b/detpic/misc.asm @@ -4,6 +4,7 @@ include common.inc code +;---------- read_pic_no ; read pic no from ID locations and return it ; W undefined pic number from ID loc 0 @@ -20,6 +21,7 @@ read_pic_no mov_fw TABLAT return +;---------- init_read_idlocs ; read id locations and store in canonical place ; W undefined undefined @@ -36,6 +38,7 @@ init_read_idlocs return +;---------- init_bitnum2bit ; populate bitnum2bit mov_lw 0x80 @@ -46,4 +49,10 @@ init_bitnum2bit_loop bra_nn init_bitnum2bit_loop return +;---------- +common_init + call bitnum2bit_init + call points_init + return + include final.inc diff --git a/detpic/morse.messages b/detpic/morse.messages index 8f5cd89..e1888f2 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -30,6 +30,9 @@ TI4 ; for iwj TI5 ; for iwj X test-sofar:ch ; bad character received from host +# Unimplemented things +UP ; unimplemented point timer setting + ZM i2clib:st,:sspstat,:sspcon1,:sspcon2 ; for testing ZS i2clib:st,:sspstat,:sspcon1,:st_orig ; for testing @@ -50,5 +53,7 @@ DQ FSR2L,:outmsg_end ; previous slave read incomplete DR FSR2L,:outmsg_end ; slave read overrun # Messages for specific peripherals -PS FSR0L ; POLARITY message too short -PL FSR0L ; POLARITY message too long +RS FSR0L ; POLARITY message too short +RL FSR0L ; POLARITY message too long + +PB points:pointmsg ; Firing point when already busy diff --git a/detpic/pindata.inc b/detpic/pindata.inc index d0c85ba..e8ce55d 100644 --- a/detpic/pindata.inc +++ b/detpic/pindata.inc @@ -1,5 +1,7 @@ ;====================================================================== + radix dec + picno2ptmap equ 0x6100 bkptix2portnumbitnum equ 0x6000 pic2detinfo equ 0x6040 @@ -7,3 +9,6 @@ picno2revbits equ 0x6080 maxpic_ln2 equ 5 maxpic equ 1 << maxpic_ln2 + +maxpoint_ln2 equ 5 +maxpoint equ 1 << maxpoint_ln2 diff --git a/detpic/points.asm b/detpic/points.asm index f58745c..51b203c 100644 --- a/detpic/points.asm +++ b/detpic/points.asm @@ -1,5 +1,119 @@ ;====================================================================== ; POINTS + +; Idle Firing +; Timer 3 Off On, counting up +; pointmsg undefined message from master + + udata_acs +pointmsg res 1 + + udata 0x300 +ptix2latbit res maxpoint * 2 ; bit and LAT* + + code + +pt_timer13_prescale equ 0 +pt_timer13_inithigh equ 0 + +;---------- +point_timer_init + mov_lw (1<> 8 + mov_wf FSR0H ; FSR0H -> table + rl_w pointmsg ; W = point addr, Z iff pt0 + mov_wf FSR0L ; FSR0 -> &LAT* [Z still iff pt0] + bt_f_if1 T3CON, TMR3ON ; Were we firing ? [Z still iff pt0] + btg_f STATUS, Z ; Z iff (pt0 xor were_firing) + bra_z point_set_pin_l +point_set_pin_h + mov_fw POSTINC0 ; W = bit, FSR0 -> &LAT* + mov_ff INDF0, FSR0L ; W = bit, FSR0L -> LAT* + set_f FSR0H ; FSR0 -> LAT*, W = bit (still) + ior_wff INDF0 ; pin = H + return + +point_set_pin_l + com_fw POSTINC0 ; W = ~bit, FSR0 -> &LAT* + mov_ff INDF0, FSR0L ; W = ~bit, FSR0L -> LAT* + set_f FSR0H ; FSR0 -> LAT*, W = bit (still) + ior_wff INDF0 ; pin = H + return + +;---------- +point_clash + panic morse_PB + + + + + bt_f_if0 + + + + + bra_z point_do_if_pt0 +point_do_ifnot_pt0 + rcall point_pin_h +point_do_endif_pt0_set_timer + mov_lw + +point_do_if_pt0 + rcall point_pin_l + + + +point_pin_l + + + rl_w + + bt_f_if0 + + add_lw (ptix2lat >> 8) - 0x80 + + + +; We use FSR1 so we have to save it + mov_ff FSR1L, fsr1l_save ; we assume FSR1H is zero, since on + ; W SS zz zz pp pp pp pp pp + +;---------------------------------------------------------------------- +points_init +; Initialises tables for points +; Clears TRIS* bits for all points and sets each pin to `not triggering' +points_init + + ; ; Expected layout of data at data_points in flash: ; 4 bytes for each point number @@ -15,6 +129,10 @@ ; bytes 1-3 are not defined if number is not assigned ; address of data_points is guaranteed to be multiple of 256 + + + + udata_acs udata 0x300 diff --git a/detpic/reverse.asm b/detpic/reverse.asm index 0a86fc1..2e0a5a1 100644 --- a/detpic/reverse.asm +++ b/detpic/reverse.asm @@ -89,7 +89,7 @@ board_next_none ;---------- polarity_do_here -; W here polarity SS SS v3 v0 v2 v1 v5 v4 +; W here polarity msg SS SS v3 v0 v2 v1 v5 v4 mov_wf input ; input = SS SS v3 v0 v2 v1 v5 v4 mov_wf LATE ; W = kk kk kk kk kk kk o5 o4 diff --git a/detpic/slave.asm b/detpic/slave.asm index 662797e..ecfcee3 100644 --- a/detpic/slave.asm +++ b/detpic/slave.asm @@ -13,10 +13,11 @@ ; picno, idloc1 containing correct values read from flash slave - call det_slave_init - mov_fw picno call i2cs_init + call common_init + call det_slave_init + mov_lw (1<