[<<][staapl][>>][..]
Thu Sep 4 18:51:32 CEST 2008

more pk2

Added accessors to the pk2 module namespace that query the current
device's properties:

box> (print-script (ProgMemWrWords))
Erase progmem (09) & EE(0B), int timed 10ms

WRITE_BITS_LITERAL #x06 #x00
WRITE_BYTE_LITERAL #x00
WRITE_BYTE_LITERAL #x00
WRITE_BITS_LITERAL #x06 #x09
DELAY_LONG #x02
WRITE_BITS_LITERAL #x06 #x0B
DELAY_LONG #x02

box> (script (ProgMemWrWords))
Erase progmem (09) & EE(0B), int timed 10ms
(238 6 0 242 0 242 0 238 6 9 232 2 238 6 11 232 2)


This required only minor modification:

;; Also create accessor thunks for properties on top of hash DB.  These
;; will get the property of the current part (makes name-checking
;; static).
(define-syntax-rule (define-reader/provide name (type id . args) ...)
  (begin
    (define-reader name (type id . args) ...)
    (begin (define (id) (property 'id)) ...)
    (provide id ...)))
(define part (make-parameter 'PIC18F1220))
(define (property tag [dev (part)])
  (let* ((part (hash-ref *part-index* dev))
         (fam  (vector-ref *family* (hash-ref part 'Family))))
    (hash-ref part tag
              (lambda ()
                (hash-ref fam tag)))))



Trying to make a device-read script now, but something is missing: the
code executes scripts on the device, but i didn't see the part where
it gets uploaded.

The lowlevel routine is
\\ PICkitFunctions.cpp
bool CPICkitFunctions::downloadScript(unsigned char scriptBufferLocation, int scriptArrayIndex)

The one that calls this is:
void CPICkitFunctions::downloadPartScripts(int familyIndex)

This is called by
void CPICkitFunctions::PrepPICkit2(void)

Which also sets VDD and Vpp voltages


Scripts start from index 1, not 0 !!

box> (SCRIPT_BUFFER_CHKSM)
(0 0 0 0)
box> (DOWNLOAD_SCRIPT 1 (script (ProgMemRdScript)))
Reads 64 words of program memory.
()
box> (SCRIPT_BUFFER_CHKSM)
(1 0 238 0)

So uploading seems to work.  Execution not though:


;; CPICkitFunctions::ReadDevice
(define (read-program-memory)
  (READ_STATUS)

  (MCLR_GND_ON)
  (EXECUTE_SCRIPT  (VDD_GND_OFF)
                   (VDD_ON))             ;; we power the device

  (EXECUTE_SCRIPT  (CLR_DOWNLOAD_BFR)
                   (DOWNLOAD_DATA 0 0 0))
  (EXECUTE_SCRIPT  (script (ProgMemAddrSetScript)))

  (CLR_SCRIPT_BFR)
  (DOWNLOAD_SCRIPT 1 (script (ProgMemRdScript)))

  (EXECUTE_SCRIPT  (CLR_UPLOAD_BFR)
                   (RUN_SCRIPT
                    1 ;; index ???
                    1 ;; repititions?
                    )
                   (UPLOAD_DATA_NOLEN)
                   (UPLOAD_DATA_NOLEN)))


I'd like to eliminate the use of 'script' too.  For printing scripts,
one should use the 'properties function.  This requires some type
spec, maybe derived from the name?




[Reply][About]
[<<][staapl][>>][..]