
Originally Posted by
azmax100
I just found out that I can't even make an Led to blink. Maybe there's a problem with the Pic itself. I will try to use another Pic this evening and try again with the code provide by arati.
I was afraid of that. So, like Joe said, lets start from scratch.
First, these are a must read:
http://www.picbasic.co.uk/forum/showthread.php?t=561
http://www.picbasic.co.uk/forum/showthread.php?t=562
http://www.picbasic.co.uk/forum/showthread.php?t=543
Now for the configs. In the PBP directory you will see *.inc files as the thread above talks about. Comment out the correct lines. Make it look like this.
Code:
NOLIST
ifdef PM_USED
LIST
include 'M16F87xA.INC' ; PM header
; device pic16F877A, xt_osc, wdt_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F877A, r = dec, w = -302
INCLUDE "P16F877A.INC" ; MPASM Header
; __config _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST
I will assume you are using Micro Code Studio. Make sure MPLAB is installed and have MCS set to use MPASM. This is not really needed for this PIC but in the future it will be so we will start off right. In MCS tool bar - View-Compiler and Program Options- then the Assembler tab. Check use MPASM.
Now for some basic code to see if all is working.
Code:
'16F877A HEART_BEAT
DEFINE OSC 20
'####################
@ __config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF &_BODEN_OFF
ADCON1=7
CMCON=7
START:
HIGH PORTD.2
PAUSE 100
LOW PORTD.2
PAUSE 100
GOTO START
When the above is working we can do a simple serial output to a terminal. MCS has on built in.
Bookmarks