Starting with an unknown board
https://plus.google.com/u/0/+JamesNewton/posts/CKnu7yU9BGv
found by a local electronics recycler:
http://www.ourplanetrecycling.com/
This board is from a muscle stimulant system for post surgery recovery, manufactured by/for, and distributed by VQ Orthocare. There are newer units to replace it now. This unit is the SurgiStim3, and has been replaced with SurgiStim4. If you power it up with >5V, and ground the third pin from the left of J2, the unit powers up, shows an opening screen from half a second or so, then goes to a screen that says your authorized time of use has elapsed and to put it in the cradle overnight for updates.
It appears that J1 is an ICSP connector. A quick run through with the meter
indicates that the pinout of the connector is ...
Pin 1 is VDD (5V),
Pin 2 is Clock,
Pin 3 is Data,
Pin 4 is Reset, and
Pin 5 is Ground.
I have verified that the PIC can indeed be erased and programmed via a PICKit3
{ed: this might be a great board for the Minimal Controller Idea }
;================================================
;
; Simple code example to test port pin and USART
; ;================================================
; Configuration
list p=18F8720
#include P18F8720.INC
CONFIG OSC = HS
CONFIG WDT = OFF
CONFIG LVP = OFF
CONFIG DEBUG = OFF
;================================================
; Variables cblock 0x20
Temp
endc
org 0
;================================================
; Initialize
init:
clrf PORTB ; Configure RB7 on PORTB for
bcf TRISB, RB7 ; digital I/O for an LED.
bcf TRISC, RC6 ; Set TRISC<6:7> to enable.
pic Pin 37 (xmt)
bsf TRISC, RC7 ; serial.
pic Pin 38 (rcv)
bcf PORTB, RB7 ; Turn LED off. pic Pin 47
movlw 0x67 ; serial eusart to 9600 (0x19 with BRGH=0)
movwf SPBRG1 ; baud.
(0x67 with BRGH=1)
movlw b'00100100' ; Enable Transmit and clear SYNC
movwf TXSTA1 ; to allow asynchronous mode.
movlw b'10010000' ; Enables Serial Port movwf
RCSTA1 ; and Continuous Receive
bcf RCSTA1, CREN ; Clear any errors by disbaling
nop ; continuous receive mode,
then bsf RCSTA1, CREN ; renable conitnuous receive mode
receive bsf PORTB, 7
movf RCREG1,W
nop
nop
btfss PIR1,5 ; (5) check for received data RC1IF
goto $ - 2
movf RCREG1,W ; save received data in W bcf
PORTB, 7
toggle: ; Toggle back and forth
btg Temp, 0 ; between loading 'U'
btfsc Temp, 0 ; and loading 'G' in the
goto load_U ; W register.
goto load_G ; ...
load_U: bsf LATB,7 ; ...
movlw 'R' ; Put 'R' in W and
call tx
movlw 'B'
call tx
movlw '7'
call tx
movlw ' '
call tx
movlw 'O' ; Put 'G' in W and
call tx
movlw 'n'
call tx
movlw 0x0A ; Put 'CR/LF' in W and transmit.
call tx
movlw 0x0D
call tx
btfss PIR1,5 ; (5) wait for received data RC1IF
goto $ - 2
movlw 'D'
subwf RCREG1,W
btfsc STATUS,Z
goto toggle
goto load_U
goto toggle
load_G: bcf LATB,7 ; ...
movlw 'R' ; Put 'G' in W and
call tx
movlw 'B'
call tx
movlw '7'
call tx
movlw ' '
call tx
movlw 'O' ; Put 'G' in W and
call tx
movlw 'f'
call tx
movlw 'f'
call tx
movlw 0x0A ; Put 'CR/LF' in W and transmit.
call tx
movlw 0x0D
call tx
btfss PIR1,5 ; (5) wait for received data RC1IF
goto $ - 2
movlw 'U'
subwf RCREG1,W
btfsc STATUS,Z
goto toggle
goto load_G
tx:
movwf TXREG ; Move W into tx register and provide
nop ; a cycle for TXIF to update.
check:
btfss PIR1, TXIF ; Wait for tx by monitoring TXIF
goto check ; Goto check while not done.
return
end