'-------------------------------< Blinky LED >------------------------------------
'
' File name : BlinkyLed.bas
' Version : 1.0
' Company : Mister E
' Programmer : Steve Monfette
' Date : June 22, 2011
' Device : PIC16F690
'
'---------------------------------------------------------------------------------
'---------------------------< Project description >-------------------------------
'
' Beginner code example to blink a Led on PORTc.0 using:
' 1) PBPDEMO version
' 2) MicroCode Studio
' 3) PICKIT 2 Programmer
'
'---------------------------------------------------------------------------------
'----------------------------< Hardware listing >---------------------------------
'
' - Microchip Low Pin Count Demo Board
' - PIC16F690 installed
' - *** All jumper have to be installed ***
' - Target board will be powered by the PICKIT 2
'
'---------------------------------------------------------------------------------
'
' Pic Configuration
' =================
' All PIC configuration fuses (Configuration bits) are listed in the
' C:\PBPDEMO\p16f690.inc file. Also see datasheet section 14.1
'
' _INTRC_OSC_NOCLKOUT: Using Internal Oscillator
' _WDT_ON: Enable Watch Dog Timer
' _MCLRE_ON: Enable MCLR
' _CP_OFF: Disable Code Protection
' _CPD_OFF: Disable Data Code Protection
' _FCMEN_OFF: Disable Fail Safe Clock Monitor
' _IESO_OFF: Disable Internal/External switchover
' _BOR_ON: Enable Brown out detect
' _PWRTE_ON: Enable Power up Timer
'
OSCCON = %01110000 ' datasheet section 3
' -x-------- n/a
' --111----- IRCF<2:0> Internal Oscillator Frequency Select Bits (8MHz)
' -----xxxx- Read Only
'
DEFINE OSC 8 ' tells PBP we use a 8 MHZ clock
'
' Hardware assignment
' ===================
' Here we assign Aliases to PORT pin
' this makes the code easier to read
' I'll use the Aliases name as written on the schematic
'
' LEDs
' ----
DS1 VAR PORTC.0
DS2 VAR PORTC.1
DS3 VAR PORTC.2
DS8 VAR PORTC.7
'
' Hardware configuration
' ======================
'
' I/Os (Datasheet section 4.0 & above)
' ------------------------------------
TRISA = 0 ' All PORTA I/O set as Output (When capable of)
TRISB = 0 ' All PORTB I/O set as Output
TRISC = 0 ' All PORTC I/O set as Output
'
' ADCs (datasheet section 9)
' --------------------------
ANSEL = %00000000 ' Set all pins digital
ANSELH = %00000000
WPUA = %00000011 ' Enable pullups for buttons
WPUB = %00000000
'
' Comparator (datasheet section 8)
' --------------------------------
' At Power On, the comparator are already disabled
' but let's play safe.
'
CM1CON0 = 0 ' Disable comparator 1
CM2CON0 = 0 ' Disable comparator 2
'
' Software/Hardware initialisation
' ================================
PORTA = 0 ' clear PORTA output pins (0v)
PORTB = 0 ' clear PORTB output pins (0v)
PORTC = 0 ' clear PORTC output pins (0v)
WHILE !OSCCON.2 : Wend ' Wait untill the internal OSC get stable
i Var Byte
'------------------------------< Main program >-----------------------------------
'
START:
iF (PORTC.7= 1) THEN
PORTC.0 = 1
ELSEIF (PORTC.7 != 1) THEN
PORTC.0= 0
ENDIF
PAUSE 1000
PORTC.0=0
GOTO Start
'
Bookmarks