; Test harness for the PWM code
;
; ### license
;
; A simple test harness. This will set different values on the 9 channels,
; then run the PWM. The idea being: wire up 9 LEDs, and observe a spectrum
; of brightness levels.
;

        list p = 16f688
        include p16f688.inc
        include ../include/handy.inc

        __config DEFAULT_CONFIG

.reset: org  0x0000
        goto main

.interrupt: org 0x0004
        ; ### we shouldn't be seeing interrupts
        retfie

; Interrupts not in use. Not worrying about the interrupt vector.

.main:  code                    ; relocatable
main:
        extern  CHAN1, CHAN2, CHAN3, CHAN4, CHAN5, CHAN6, CHAN7, CHAN8, CHAN9

        bank1

        ; Switch to running at 8 Mhz
        movlw   0x70
        iorwf   OSCCON, F

        bank0s

        ; Initialize the 9 channel values at 11%, 22% ... 99%
        ; Note: perceived brightness is logarithmic
        movlw   0x05
        movwf   CHAN1
        movlw   0x0a
        movwf   CHAN2
        movlw   0x10
        movwf   CHAN3
        movlw   0x19
        movwf   CHAN4
        movlw   0x28
        movwf   CHAN5
        movlw   0x40
        movwf   CHAN6
        movlw   0x65
        movwf   CHAN7
        movlw   0xa1
        movwf   CHAN8
        movlw   0xff
        movwf   CHAN9

        extern  run_PWM
        call    run_PWM

        ; run_PWM should never exit


; stupid assemblers don't realize EOF means *end*
        end
