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

PICBASIC PRO program for recovering factory OSCCAL calibration values. Run this program in a 12F675 on the LAB-X4 Experimenter Board. It will display gibberish on the LCD until the calibration value is incremented to a value that lets the serial communication work. It will continue to display hex calibration values until incremented beyond the working range. Let it run, monitor the LCD for values followed by "Correct?". Pick one of the values that work - midway after it starts working and before it stops working.
' Name        : RECOVER.pbp
' Compiler    : PICBASIC PRO Compiler 2.6
' Assembler   : PM or MPASM
' Target PIC  : 8-pin PIC12F675 or similar types
' Hardware    : Lab-X4 board
' Oscillator  : 4MHz internal
' Keywords    : SEROUT2, OSCCAL
' Description : PICBASIC PRO program for recovering factory OSCCAL calibration values.
' Run this program in a 12F675 on the LAB-X4 Experimenter Board.
' It will display gibberish on the LCD until the calibration value is incremented to a
' value that lets the serial communication work.  It will continue to display hex
' calibration values until incremented beyond the working range.  Let it run, monitor
' the LCD for values followed by "Correct?".  Pick one of the values that work - midway
' after it starts working and before it stops working.
'

LCD Var GPIO.1  ' LCD TX pin

   ANSEL = 0    ' disable A/D converter
   CMCON = 7    ' disable comparators
   OSCCAL = 0   ' starting value for OSCCAL register

   Pause 200  ' give the LCD time to start up

mainloop:
   OSCCAL = OSCCAL + $10     ' increment calibration value

   ' Test to see if the serial comm works. 
   Serout2 LCD,396,[$fe, 1]  ' Clear screen
   Serout2 LCD,396,[HEX2 OSCCAL, "   Correct?"] ' Display the hex value  
        
   Pause 750       ' give time to read the value
   goto mainloop   ' do it forever

   End


           

Download the program file.