I am trying to get a PIC18F4620 to blink a LED.
I think I have enough hardware bit I cannot get it to work.
Code:
'****************************************************************
' Name : BLINK.pbp Based on the MeLabs code examples for Lab-X1
' Compiler : PICBASIC PRO Compiler 3.0.7.4
' IDE : MCSP 5.0.0.5
' Assembler : MPASM
' Target PIC : 18F4620 in 40 pin PDIP.
' Oscillator : internal IntRC (Clkout) set in Config fuse at code burn time
' Programmer : MeLabs U2 USB
' Keywords : BLINK LED
' Description : Minimal hardware PIC18F4620 in 40 pin DIP
'****************************************************************
'
'The following program is a simple test to blink an LED on and off.
' Hardware : minimal breadboard 7805, input cap, output cap
'
'pin 1 = reset, tied to +5
'pin 11 +5V
'Pin 12 Gnd
'1 uF cap between pins 11 & 12
'Pin 31 Gnd
'Pin 32 +5V
'1 uF cap between pins 31 & 32
'Pin 33 Port B.0 has LED to Gnd via 1k resistor
'Program is compiled with PBP3.0.7.4 and MCSP 5.0.0.5
'At program time the IntRC (ClkOut) oscillator is selected.
LED1 VAR PORTB.0 ' Assign name "LED1" to PORTB.0 on pin 33
OSCCON = %11111111 '
' 0------- IDLEN 0 = enters SLEEP on Sleep command = 4 uA
' 1------- Enters IDLE and draws 550 uA
' -111---- IRCF <2:0> Int Osc freq select 111 = 8 MHz
' ----0--- OSTS Osc Startup Status - read only - ignore
' -----0-- IOFS IntOsc Freq Stable - read only - ignore
' ------00 System Clock Select 00 = Primary Osc
WDTCON = %00000001 ' enables SWDT - needs WDT OFF in config
' xxxxxxx1 SWDTEN software controlled WDT enabled
ADCON0 = %00000000 ' ADC OFF
' xx0000-- CH<3:0> select analog channels
' ------0- 1 = Go, 0 = Done
' -------0 1 = ADC ON, 0 = ADC OFF
ADCON1 = %00001111 'VRefs = Vdd & Vss, All ports digital
' 00------ unimplimented
' --00---- VCFG<1:0> Select Vcc & Gnd as ADC references
' ----0110 PCFG<3:0> A/D Port configuration see register 19-2
' ADCON2 = %00111111 'Left just (=8 bit), ADacq time = 20 Tad, ADClk = Frc
' 0------- ADFM 0 = Left Justified 8 bit mode
' -x111--- ACQ<2:0> A/D acquisition time = 20 Tad
' -----111 ADCS<2:0> A/D conversion clock select = Fr/c
CMCON = %00000111 ' Comparators OFF
' 00------ No comparator outputs
' --00---- No inversion on outputs
' ----0--- Vin to pins AN0 & AN1
' -----111 Comparators OFF
mainloop:
High LED1 ' Turn on LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds
Low LED1 ' Turn off LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds
Goto mainloop ' Go back to loop and blink LED forever
End
When I program the PIC I select INTRC(ClkOut) as the clock option
Any help gratefully received.
Thanks
BrianT
Bookmarks