[<<][pk2][>>][..]
Sat Mar 26 13:07:59 EDT 2011

Send out a data packet using standard PIC protocol.

Start at 
pk2.ss: write-program-memory

Now hook scope to the data and clock lines.


  ICD2    serial                 color

1 /MCLR                          white
2 VDD                            red
3 GND                            black
4 PGD     RX  (<- target TX/CK)  yellow
5 PGC     TX  (-> target RX/DT)  orange
6 PGM


Ok I got scope setup to capture the data.  ( Still learning how to use
the Rigol.  Got some weird readings with propes on 10x.. )



The command to use is WRITE_BITS_BUFFER, which clocks out 1-8 bits
from the Downstream Data Buffer and increments the pointer.

I got something working using this:

1. use the pk2cmd program to program the chip
2. (enter-programming 0)
3. (EXECUTE_SCRIPT (WRITE_BITS_LITERAL 8 #xAA))

So this means that at least some init is not done properly, and the
`enter-programming' performs some init that's necessary.


Got the dasm working (damn, I did hide the data pretty deep!) and this
is what thats cript does:


	VPP_OFF
	MCLR_GND_ON
	VPP_PWM_ON
	BUSY_LED_ON
	SET_ICSP_PINS 0
	DELAY_LONG 20
	MCLR_GND_OFF
	VPP_ON
	DELAY_SHORT 127
	MCLR_GND_ON
	VPP_OFF
	VPP_ON
	MCLR_GND_OFF
	DELAY_LONG 19


So, reduced it to

  (reset-hold)
  (target-on)
  (EXECUTE_SCRIPT
     (SET_ICSP_PINS 0)
     (WRITE_BITS_LITERAL 8 byte))


And indeed the 2 first commands are not necessary.  


Final word:

(define (icsp-send bytes)
  (when (> (length bytes) 29)
    (error 'buffer-overflow))
  (apply EXECUTE_SCRIPT
         (cons (SET_ICSP_PINS 0)
               (for/list ((b bytes))
                 (WRITE_BYTE_LITERAL b)))))
   

For receive I'll need to use buffers.



[Reply][About]
[<<][pk2][>>][..]