[<<][staapl-blog][>>][..]
Tue Sep 9 16:55:33 CEST 2008

Blink-A-Led

The example can be found here:
http://zwizwa.be/darcs/staapl/staapl/examples/blink-a-led.f

Complete recipe:

  * Install PLT Scheme v4.1 or higher from http://plt-scheme.org

  * Run "mzscheme -p zwizwa/staapl/install" to download and compile
    the Staapl code. This creates a wrapper command line application
    called "staaplc".

  * Copy-Paste the code below, or download it from the link given
    above and run "staaplc blink-a-led.f" to the PIC18F452.

  * Upload the generated blink-a-led.hex

You don't need the full PLT distro to run Staapl.  If space is an
issue, download just MzScheme from:
http://pre.plt-scheme.org/installers

The example will probably work on other PIC18 chips, but you might
need to tweak the configuration bits.

I just noticed this example doesn't initialize the stack pointers.
Add this definition and call it in init.

: init-stacks
      #x7F 0 lfsr            \ DATA stack 16 bytes at #x80
      #x8F 1 lfsr            \ AUX stack  16 bytes at #x90
      0 movlw STKPTR movwf   \ hardware return stack
;

---- cut here ----

\ stand-alone BLINK-A-LED for PIC18F452

load p18f452.f

\ config bits (40 MHz XTAL)
#x300000 org
  #x00 , #x26 , #x0F , #x0E ,
  #x00 , #x01 , #x81 , #x00 ,
  #x0F , #xC0 , #x0F , #xA0 ,  \ B: boot write protect
  #x0F , #x40 ,

\ we just start at the head of flash memory
0 org

: main     init begin blink busyloop again

: init     0 LATB ! 0 TRISB ! ;
: blink    LATB 0 toggle ;

\ The inner loop takes 3 cycles to execute. [DECF + BNZ]
: busyloop 100 for 100 for 100 for next next next ;




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