ME Labs, Inc.
719-520-5323
 
Home:
  Developer Resources:

Programming Clues
    Sample Programs
   
    PICBASIC PRO™
Compiler Manual
    PICBASIC™ Compiler
Manual
    Serin2/Serout2 Modes
    ASCII Character Set
    Number Conversion
    Floating Point
Routines
    PBP Debug Monitor
    Articles and Tutorials

Hardware Clues
    Parts / Vendor List
    PICPROTO™ Boards
    LAB-X1 Docs
    LAB-X2 Docs
    LAB-X20 Docs
    LAB-X3 Docs
    LAB-X4 Docs
    LAB-XUSB Docs
    LAB-XT Docs
     
 

ME Labs, Inc. | 1-719-520-5323 | Example Program - RWCODEX.pbp

PICBASIC PRO program to read and write to code space Flash Program Write must be enabled on your programmer. Writes to 8 locations of code space beginning at $1800. Reads 8 locations back and sends to LCD repeatedly.
' Name        : RWCODEX.pbp
' Compiler    : PICBASIC PRO Compiler 2.6
' Assembler   : PM or MPASM
' Target PIC  : 40-pin 16F877A, 18F452 or similar
' Hardware    : LAB-X1 Experimenter Board
' Oscillator  : 4MHz external crystal
' Keywords    : READCODE, WRITECODE, LCDOUT
' Description : PICBASIC PRO program to read and write to code space
' Flash Program Write must be enabled on your programmer. Writes to 8
' locations of code space beginning at $1800. Reads 8 locations back 
' and sends to LCD repeatedly.
'

' Define LCD registers and bits
Define LCD_DREG  PORTD
Define LCD_DBIT  4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG  PORTE
Define LCD_EBIT  1

I Var byte       ' Loop count
D Var byte       ' Data
A Var word       ' Address

   ADCON1 = 7    ' Set PORTA and PORTE to digital
   Low PORTE.2   ' LCD R/W line low (W)
   Pause 100     ' Wait for LCD to start up

   For I = 0 To 7   ' Loop 8 times, once for each address $1800 to $1807
     A = $1800 + I  ' Increment Address
     D = I + $A0    ' Change Data
     Writecode A,D  ' Send value in D to code space location A
   Next I

mainloop:
   For I = 0 To 7   ' Loop 8 times, once for each address $1800 to $1807
     A = $1800 + I  ' Increment Address
     Readcode A,D   ' Get data in location A
     Lcdout $fe,1,hex A,": ",hex D ' Display the location and data
     Pause 1000
   Next I
   Goto mainloop

   End

           

Download the program file.