The next is a example of code made for PICBASIC, I got it from internet made by Melanie.
I want to change it to Proton, I made only litle changes to use with PIC16F630, and I tested and it works, but I need use PROTON...
THANKS a lot
' Program BatLo
' ============
' Embedded Software Version 1.00
' Target Processor PIC16F628-04/P
' Target PCB BB-001
' Created 09/04/02
' Last Updated 09/04/02
' Written by Melanie Newman
'
' Melanies very complicated Battery Low Indicator
'
'
' Device Programming Options
' --------------------------
@ DEVICE pic16F630, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F630, WDT_ON
' Watchdog Timer
@ DEVICE pic16F630, PWRT_ON
' Power-On Timer
@ DEVICE pic16F630, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F630, BOD_ON
' Brown-Out Detect
'@ DEVICE pic16F630, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F630, CPD_OFF
' Data Memory Code Protect
@ DEVICE pic16F630, PROTECT_OFF
' Program Code Protection
'
' Hardware Assignments
' --------------------
BatVal var CMCON.6
' Read Comparator 2 for Battery Low
' Port RA1 has +VBatt Input
BatLoLED var PORTC.5
' Port for Battery Low LED
'
' Start Program
' ============
'
' Setup Hardware
' --------------
'
' Comparator Control
' ------------------
CMCON=%00010101
'bit 7 Unimplemented: Read as ‘0’
'bit 6 COUT: Comparator Output bit
'When CINV = 0:
'1 = VIN+ > VIN-
'0 = VIN+ < VINWhen
'CINV = 1:
'1 = VIN+ < VIN-
'0 = VIN+ > VINbit
'5 Unimplemented: Read as ‘0’
'bit 4 CINV: Comparator Output Inversion bit
'1 = Output inverted
'0 = Output not inverted
'bit 3 CIS: Comparator Input Switch bit
'When CM2:CM0 = 110 or 101:
'1 = VIN- connects to CIN+
'0 = VIN- connects to CINbit
'2-0 CM2:CM0: Comparator Mode bits
'Figure 6-2 shows the Comparator modes and CM2:CM0 bit settings
'' Voltage Reference Control
' -------------------------
VRCON=%11101100
' bit 7 VREN: CVREF Enable bit
'1 = CVREF circuit powered on
'0 = CVREF circuit powered down, no IDD drain
'bit 6 Unimplemented: Read as '0'
'bit 5 VRR: CVREF Range Selection bit
'1 = Low range
'0 = High range
'bit 4 Unimplemented: Read as '0'
'bit 3-0 VR3:VR0: CVREF value selection 0 VR [3:0] 15
'When VRR = 1: CVREF = (VR3:VR0 / 24) * VDD
'When VRR = 0: CVREF = VDD/4 + (VR3:VR0 / 32) * VDD
Pauseus 10
' Delay to allow for VREF to settle
' see datasheet section 11-1
'
' And the Usual Stuff
' -------------------
TRISA=%11111111 ' Set All Inputs
TRISC=%00000000 ' Set All Outputs
'
' Actual Program
' --------------
BatLoLoop:
BatLoLED=BatVal
' You better believe it... just ONE line of code!
Goto BatLoLoop
'
End