Hi larzazral
Check what Joe said and read it all carefully and then check if you have an external oscillator (20 MHZ crystal).
In the code below I have the defines setup and also ocsillator setting for the internal clock , code is commented as much as possible!
Hope this helps
Dennis
Code:
'*************************************
'Blink and LED for 16F887 on PORTd.2
'*************************************
'Un-comment the lines below if you need to
'@__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & '_LVP_OFF & _CP_OFF
'Ocsillator selections here
'OSCCON = %01100001 for 4mhz, or OSCCON = %01110001for 8mhz
' OSCCON = %01110001 'Int CLK 8MHz
' ANSEL= %11111111 '$0F = disable A/D converter
' option_reg = 7 'switch pull-ups ON
'END of oscillator selections
'timer/oscillator defines
OSCCON = %01110001 'Int CLK 8MHz
DEFINE OSC 8 '8MHz << NOTICE UPPERCASE ON DEFINE
'END of timer/oscillator defines
ANSEL = %00000000 'All digital
OPTION_REG.7 = 0 'Weak pull-ups enabled
'port clear
PORTA=0
PORTB=0
PORTC=0
PORTD=0
PORTE=0
'end of port clear
'Port IO directions and presets for port pins begin here
'TRISX = %76543210 << TRIS bit order numbering
'TRISA = %11111111 << 'All pins are outputs
'// Define port pins as inputs and outputs ...
TRISA = %00000000 'all output
TRISB = %00000000 'all output
TRISC = %00000000 'all output
TRISD = %00000000 'all output
TRISE.0 = 0 'all output
TRISE.1 = 0 'all output
TRISE.2 = 0 'all output
'End of Port IO directions and presets for port pins begin here
'includes begin here
INCLUDE "modedefs.bas"
'end of includes
'variables begin here
LED var PORTd.2 ' Alias PORTD.0 to LED
'end of variables
blinky: ' a program label called blinky
high LED ' LED on
Pause 500 ' Delay for .5 seconds
low led 'LED off
Pause 500 ' Delay for .5 seconds
Goto blinky ' Go back to blinky label and do it all over again
End
'End of all code
Bookmarks