--- /dev/null
+
+
+
+ include /usr/share/gputils/header/p18f458.inc
+
+ code
+
+; initialise booster direction
+ bcf TRISC,0,0 ; make pin 0 (booster direction) output
+ bcf PORTC,0,0 ; set low initially
+
+
+; set booster pwm high
+ bcf TRISC,1,0 ; make pin 1 (booster pwm) output
+ bsf PORTC,1,0 ; booster pwm high
+
+loop
+ goto loop
+
+ end
debug '3' ; write 'h' to serial port
; *** check for overrun and do something sensible
btfss INDF0,7,0 ; check if bit 7 is set
- debug '4' ; write 'h' to serial port
call advance_write_buffer ; if so, move to next buffer
- debug '5' ; write 'h' to serial port
+ debug '4' ; write 'h' to serial port
retfie 1
; *** I *think* the interrupt bit is cleared by reading out of RCREG
; if not zero, clear low 4 bits of FROMSERIAL and increment top 4 bits
; aaaabbbb -> bbbbaaaa -> bbbb(aaaa+1) -> 0000(aaaa+1) -> (aaaa+1)0000
+ debug '5' ; write 'h' to serial port
swapf FROMSERIAL,1,0
incf FROMSERIAL,1,0
movlw 0xF
fromserial_overflow
; clear bit 6 (will set back to buffer 0 if has overflowed to 4)
+ debug '6' ; write 'h' to serial port
bcf FROMSERIAL,6,0
return
btfsc NMRACTRL,NEXTACTION,0
goto toggle_output
bsf NMRACTRL,NEXTACTION,0
+ debug '1' ; write 'k' to serial port
retfie 1
bsf NMRACTRL,NEXTACTION,0
btfss NMRACTRL,TRANSMITBIT,0
bcf NMRACTRL,NEXTACTION,0
+ debug '2' ; write 'k' to serial port
retfie 1
bnz read_from_buffer
bsf NMRACTRL,TRANSMITBIT,0
bsf NMRACTRL,NEXTACTION,0
+ debug '3' ; write 'k' to serial port
retfie 1
; if currently on bit 7, want to skip to bit 6
;*** wouldn't it be easier to start on bit 6 ? :-) -iwj
+ btfsc TOTRACKBIT,7,0
+ debug '4' ; write 'o' to serial port
btfsc TOTRACKBIT,7,0
rrncf TOTRACKBIT,1,0 ; rotate mask right
movlw 5
movwf FSR1H,0 ; set high byte of IND1 pointer
movff INDF1,WREG
- andwf TOTRACKBIT,0,0 ; mask out bit to be transmitted
-;*** to `mask out' means to clear, eg
-;*** if you were to `mask out bit 0 of 0xff' you'd get 0xfe
-;*** I suggest `test bit to be transmitted' or `check bit ...' or maybe
-;*** `select bit ...' -iwj
+ andwf TOTRACKBIT,0,0 ; select bit to be transmitted
bz zero_bit_to_track
bra one_bit_to_track
;*** can use branch if negative. -iwj
btfsc TOTRACKBIT,7,0
call advance_pointer
+ debug '5' ; write 's' to serial port
retfie 1
; if not zero, clear low 4 bits of TOTRACK and increment top 4 bits
; aaaabbbb -> bbbbaaaa -> bbbb(aaaa+1) -> 0000(aaaa+1) -> (aaaa+1)0000
+ debug '7' ; write 'v' to serial port
swapf TOTRACK,1,0
incf TOTRACK,1,0
movlw 0xF
andwf TOTRACK,1,0
swapf TOTRACK,1,0
+ debug '8' ; write 'v' to serial port
totrack_overflow
; clear bit 6 (will set back to buffer 0 if has overflowed to 4)
bcf TOTRACK,6,0
+ debug '9' ; write 'v' to serial port
+ retfie 1
; write na=cb=1 and return
; (will be on bit 7 at this point anyway so no need to change TOTRACKBIT)
incf TOTRACK,1,0
+ debug '6' ; write 'v' to serial port
retfie 1
debug '3' ; write 'h' to serial port
; *** check for overrun and do something sensible
btfss INDF0,7,0 ; check if bit 7 is set
- debug '4' ; write 'h' to serial port
call advance_write_buffer ; if so, move to next buffer
- debug '5' ; write 'h' to serial port
+ debug '4' ; write 'h' to serial port
retfie 1
; *** I *think* the interrupt bit is cleared by reading out of RCREG
; if not zero, clear low 4 bits of FROMSERIAL and increment top 4 bits
; aaaabbbb -> bbbbaaaa -> bbbb(aaaa+1) -> 0000(aaaa+1) -> (aaaa+1)0000
+ debug '5' ; write 'h' to serial port
swapf FROMSERIAL,1,0
incf FROMSERIAL,1,0
movlw 0xF
fromserial_overflow
; clear bit 6 (will set back to buffer 0 if has overflowed to 4)
+ debug '6' ; write 'h' to serial port
bcf FROMSERIAL,6,0
return
btfsc NMRACTRL,NEXTACTION,0
goto toggle_output
bsf NMRACTRL,NEXTACTION,0
+ debug '1' ; write 'k' to serial port
retfie 1
bsf NMRACTRL,NEXTACTION,0
btfss NMRACTRL,TRANSMITBIT,0
bcf NMRACTRL,NEXTACTION,0
+ debug '2' ; write 'k' to serial port
retfie 1
bnz read_from_buffer
bsf NMRACTRL,TRANSMITBIT,0
bsf NMRACTRL,NEXTACTION,0
+ debug '3' ; write 'k' to serial port
retfie 1
; if currently on bit 7, want to skip to bit 6
;*** wouldn't it be easier to start on bit 6 ? :-) -iwj
+ btfsc TOTRACKBIT,7,0
+ debug '4' ; write 'o' to serial port
btfsc TOTRACKBIT,7,0
rrncf TOTRACKBIT,1,0 ; rotate mask right
movlw 5
movwf FSR1H,0 ; set high byte of IND1 pointer
movff INDF1,WREG
- andwf TOTRACKBIT,0,0 ; mask out bit to be transmitted
-;*** to `mask out' means to clear, eg
-;*** if you were to `mask out bit 0 of 0xff' you'd get 0xfe
-;*** I suggest `test bit to be transmitted' or `check bit ...' or maybe
-;*** `select bit ...' -iwj
+ andwf TOTRACKBIT,0,0 ; select bit to be transmitted
bz zero_bit_to_track
bra one_bit_to_track
;*** can use branch if negative. -iwj
btfsc TOTRACKBIT,7,0
call advance_pointer
+ debug '5' ; write 's' to serial port
retfie 1
; if not zero, clear low 4 bits of TOTRACK and increment top 4 bits
; aaaabbbb -> bbbbaaaa -> bbbb(aaaa+1) -> 0000(aaaa+1) -> (aaaa+1)0000
+ debug '7' ; write 'v' to serial port
swapf TOTRACK,1,0
incf TOTRACK,1,0
movlw 0xF
andwf TOTRACK,1,0
swapf TOTRACK,1,0
+ debug '8' ; write 'v' to serial port
totrack_overflow
; clear bit 6 (will set back to buffer 0 if has overflowed to 4)
bcf TOTRACK,6,0
+ debug '9' ; write 'v' to serial port
+ retfie 1
; write na=cb=1 and return
; (will be on bit 7 at this point anyway so no need to change TOTRACKBIT)
incf TOTRACK,1,0
+ debug '6' ; write 'v' to serial port
retfie 1