From: ian Date: Sat, 10 Dec 2005 03:06:51 +0000 (+0000) Subject: panic crash dump seems to work on slave and test-sofar master end is probably good... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=e9fd5e174bfaf48e0380ddfd5aac9d0a58ed7880;p=trains.git panic crash dump seems to work on slave and test-sofar master end is probably good enough to drive it; next thing is to write a hostside dumper --- diff --git a/detpic/i2clib.asm b/detpic/i2clib.asm index 4244e91..4277705 100644 --- a/detpic/i2clib.asm +++ b/detpic/i2clib.asm @@ -425,7 +425,7 @@ init_enable ; (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. +; handler and are supposed to finish with return. ; Some macros: @@ -482,8 +482,7 @@ s_event_bad_intr ;---------- s_event_idle_addrrecvread bs_f st, st_awaiting - call i2csu_read_begin ; 26cy until 1st insn of read_begin - retfie_r + goto i2csu_read_begin ; 26cy until 1st insn of read_begin ;---------- s_event_reading @@ -492,12 +491,14 @@ s_event_reading mov_fw SSPSTAT xor_lw 0xac ; D,!P, S,R,!BF bra_nz s_event_reading_not_another - call i2csu_read_another + goto i2csu_read_another ; 24cy until 1st insn of i2csu_read_another + +;---------- s_event_reading_datanack - retfie_r + return -;... +;---------- s_event_reading_not_another ; Whatever is happening, we're done reading now ! clr_f st @@ -537,7 +538,7 @@ s_write_slurpbyte ; i2c controller waiting due to SEN etc continuing with next byte mov_fw SSPBUF bs_f SSPCON1, CKP - retfie_r + return ;---------- s_event_writing @@ -563,22 +564,17 @@ s_event_writing and_lw 0xc7 ; ?D_A, ?P; ?S xor_lw 0x80 ; SMP, !CKE, !R_W, !UA, !BF bra_nz s_event_bad - retfie_r + return ;---------- s_event_writing_datarecv rcall s_write_slurpbyte bt_f_if1 st, st_subsequent - bra s_event_writing_datarecv_subsequent + goto i2csu_write_another bs_f st, st_subsequent - call i2csu_write_begin - retfie_r - -s_event_writing_datarecv_subsequent - rcall i2csu_write_another - retfie_r + goto i2csu_write_begin ;====================================================================== diff --git a/detpic/i2clib.inc b/detpic/i2clib.inc index 2dbf460..93da997 100644 --- a/detpic/i2clib.inc +++ b/detpic/i2clib.inc @@ -95,10 +95,10 @@ ; ; For i2cm_interrupt, the main program's interrupt handler is ; responsible for saving W and the flags register and other -; interrupt-related administrivia. For i2cs_interrupt, it must -; be the only high-priority interrupt source and expects to -; be vectored to directly from the interrupt handler (and it -; will retfie_r). +; interrupt-related administrivia. For i2cs_interrupt, it must be the +; only high-priority interrupt source and expects to be called from +; the interrupt handler (and it will return; the caller must +; retfie_r). ; ; If there is an i2c interrupt, the i2c?_interrupt will service it, taking ; any necessary action including calling appropriate diff --git a/detpic/panic.asm b/detpic/panic.asm index ad0b877..23f6a8c 100644 --- a/detpic/panic.asm +++ b/detpic/panic.asm @@ -23,8 +23,9 @@ psave_fsr0 res 2 psave_fsr1 res 2 psave_prod res 2 -panicst res 1 -panicst_acked equ 7 +panicst res 1 +panicst_restart_i2c equ 7 +panicst_acked equ 5 panic_vars_section udata 0x060 ; not available via access bank panic_vars @@ -53,7 +54,7 @@ panic_routine ; reconfigure timer0 for writing diagnostic msg to the LED mov_ff INTCON, psave_intcon - clr_f INTCON ; disable all interrupts EVER + bc_f INTCON, GIEH ; disable all interrupts mov_ff BSR, psave_bsr banksel panic_vars @@ -82,9 +83,14 @@ panic_routine mov_ff PRODH, psave_prod+1 clr_f panicst + bs_f picno, picno_panicd call panic_kill_hook +;x bt_f_if1 SSPCON1, SSPEN +;x bs_f panicst, panicst_restart_i2c +;x bc_f SSPCON1, SSPEN + ; re-initialise timer0 config call read_pic_no bra_z panic_setup_if_master @@ -293,7 +299,7 @@ waiting mov_wf TMR0L ; set timer0 low byte - timer now set waiting_loop ; wait for timer0 interrupt, or some other interrupt bt_f_if1 INTCON,TMR0IF - return + bra waiting_done bt_f_if0 SSPCON1, SSPEN bra waiting_loop ; no readouts if i2c is disabled @@ -301,10 +307,27 @@ waiting_loop ; wait for timer0 interrupt, or some other interrupt bt_f_if1 idloc1, idloc1_master bra waiting_loop ; no readouts on master yet - call i2cs_interrupt ; check for i2c interrupt + bt_f_if1 PIR1, SSPIF + call i2cs_interrupt bra waiting_loop +;---------- +waiting_done +;x bt_f_if0 panicst, panicst_restart_i2c + return + bc_f panicst, panicst_restart_i2c + mov_lw picno + and_lw 0x7f + bra_z waiting_done_if_master + call i2cs_init +lgl + call led_green + bra lgl + goto i2cs_init + +waiting_done_if_master + return ;**************************************************************************** ; MEMORY READOUT diff --git a/detpic/slave.asm b/detpic/slave.asm index fdc9fe2..3de928c 100644 --- a/detpic/slave.asm +++ b/detpic/slave.asm @@ -19,10 +19,10 @@ slave call points_local_init call polarity_local_init call detect_local_init - call QQ_detect_slave_init + call detect_slave_init - mov_lw (1< is clear +; +; ^ set top bit of first byte of buffer +; +; , i2cm_read_another } if readwrite is zero ; . i2cm_read_done } then these are not called; ; } instead, we count down automatically ; -; SPC set buffer pointer to start, set that byte to 0xff -; 0 set buffer pointer to start, clear that byte -; other append char to buffer, clear byte at buffer pointer +; SPC set buffer pointer to start, select reading (manual) +; 0 set buffer pointer to start, select writing +; other append char to buffer, select writing ; ; + turn on booster (polarity=L) and cdu ; $ toggle hex mode for reading ; ; Output characters: -; SPC i2cmu_done (only if readnext_counter<7> is set; -; if it is clear we store 0xff in -; readnext_counter) +; SPC i2cmu_done (writing or manual reading) ; other i2cmu_read_got_byte -; -; On slave PIC: -; we maintain a circular buffer with a separate -; read and write pointer, initially initialised to -; 01234567 (ascii) -; ^ -; i2csu_write_begin sets led to red, writes byte to buffer -; i2csu_write_another writes byte to buffer -; i2csu_write_done writes '$' to current buffer loc, sets led to black -; i2csu_read_begin sets led to green, reads byte from buffer -; i2csu_read_another reads byte from buffer -; i2csu_read_done sets led to black -; special byte values that when written aren't just -; writen to the buffer: -; < reset read and write pointers -; ! do that and also erase buffer -; set led to red when writing, blue when reading ; ;====================================================================== @@ -86,7 +67,11 @@ ch res 1 mode res 1 mode_readhex equ 0 -readnext_counter res 1 + +readwrite res 1 + ; ff means we're writing or going to write, FSR1 + ; 00 means we're to read interactively + ; 01-0f is counter of bytes to read delay_countfast res 1 delay_countmedium res 1 @@ -103,7 +88,7 @@ master_interrupt_high ; ; buffer is 0x200 onwards ; FSR0 is buffer pointer -; FSR1 permanently points to start of buffer +; FSR2 is the write cursor master clr_f mode @@ -114,14 +99,14 @@ master mov_lfsr 0x0200, 1 rcall m_buffer_reset - set_f INDF1 - set_f readnext_counter + clr_f readwrite mov_lw '|' rcall serial_write_char - mov_lw (1<