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 - EEWORD.pbp

PICBASIC PRO program demonstrating how to READ and WRITE word variables to on-board EEPROM. Word is used to add 1000 to each location address and store the result. The word data must be stored as 2 separate bytes.
' Name        : EEWORD.pbp
' Compiler    : PICBASIC PRO Compiler 2.6
' Assembler   : PM or MPASM
' Target PIC  : Any type with internal EEPROM
' Hardware    : Non specific
' Oscillator  : internal or external
' Keywords    : READ, SEROUT, WRITE
' Description : PICBASIC PRO program demonstrating how to READ and WRITE
' word variables to on-board EEPROM. Word is used to add 1000 to each 
' location address and store the result.  The word data must be stored as
' 2 separate bytes.
'

INCLUDE "modedefs.bas"  ' Include serial modes

SO VAR PORTC.6          ' Define serial output pin
B1 VAR BYTE		' Address variable
W2 VAR WORD		' Data variable

mainloop:   
   For B1 = 0 To 12 step 2	' Step 2 because each word requires 2 bytes of memory
     W2 = B1 + 1000          	' Add 1000 to address
     Write B1, W2.HIGHBYTE	' Write high byte of word
     Write B1+1, W2.LOWBYTE	' Write low byte of word to next address
   Next B1

   For B1 = 0 To 12 step 2	' Step 2 to get word size data
     Read B1, W2.HIGHBYTE	' Read high byte
     Read B1+1, W2.LOWBYTE	' Read low byte
     SerOut SO,T2400,[#W2," ",10,13] ' Display the word data
   Next B1
		
   SerOut SO,T2400,[10,13,10,13]' Skip 2 Lines
   GoTo mainloop                ' Forever

   End


           

Download the program file.