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

PICBASIC PRO program to test LAB-X3 board.
' Name        : TESTX3.pbp
' Compiler    : PICBASIC PRO Compiler 2.6
' Assembler   : PM or MPASM
' Target PIC  : PIC16F627A or similar 18-pin type compatible with LAB-X3 board
' Hardware    : LAB-X3 Experimenter Board
' Oscillator  : 4MHz external crystal
' Keywords    : HSERIN, HSEROUT, LCDOUT
' Description : PICBASIC PRO program to test LAB-X3 board.
'

' Define LCD registers and bits
Define LCD_DREG  PORTA
Define LCD_DBIT  0
Define LCD_RSREG PORTA
Define LCD_RSBIT 4
Define LCD_EREG  PORTB
Define LCD_EBIT  3

' Alias pins
S1   Var PORTB.7
S2   Var PORTA.5
LED1 Var PORTB.4
LED2 Var PORTB.5

' Allocate variables
char Var Byte
x    Var Byte

   CMCON = 7       ' Set PORTA to digital
   Pause 100       ' Wait for LCD to start
   Goto mainloop   ' Skip subroutines

' Subroutine to get a char from serial port
getchar:
   char = 0
   Hserin 0, tlabel, [char]

tlabel:
   Hserout [$55]
   Return

mainloop:
   OPTION_REG.7 = 1 ' Disable PORTB pullups to read pot

   Pot PORTB.0, 127, x
   Lcdout $fe, 1, "pot=", #x ' Send values to LCD

   Gosub getchar     ' Get char from serial port

   If char = $55 Then
      Lcdout $fe, $c0, "loopback"
   Endif

   OPTION_REG.7 = 0  ' Enable PORTB pullups for button

   If !S1 Then       ' Check switch 1
      High LED1      ' Turn on LED 1
   Else
      Low LED1       ' Turn off LED 1
   Endif

   If !S2 Then       ' Check switch 2
      High LED2      ' Turn on LED 2
   Else
      Low LED2       ' Turn off LED 2
   Endif

   Pause 200         ' Do it all about 5 times a second
   Goto mainloop     ' Do it forever

   End

           

Download the program file.