|
|
View previous topic :: View next topic |
Author |
Message |
groston
Joined: 06 Mar 2007 Posts: 6
|
Getting started - missing something obvious |
Posted: Fri Mar 09, 2007 5:22 pm |
|
|
I am trying to get the PIC-equivalent 'Hello Word!" program running. Here is my code - all seven lines of it:
Code: | #include <16F88.h>
#fuses HS,NOWDT,NOPROTECT,INTRC
#use delay(internal=4M)
void main()
{
output_bit (PIN_B1, 1);
delay_ms(500);
output_bit (PIN_B1, 0);
delay_ms(500);
} |
I am using the command line version of CCS within MPLAB 7.50. I believe that I am properly communicating with the PIC because after compiling and programming, I get the following messages:
Quote: | Programming Target...
...Validating configuration fields
...Erasing Part
...Programming Program Memory (0x0 - 0x3F)
Verifying...
...Program Memory
...Verify Succeeded
Programming Configuration Bits
.. Config Memory
Verifying configuration memory...
...Verify Succeeded
...Programming succeeded
09-Mar-2007, 18:17:04
MPLAB ICD 2 Ready
|
The problem is that the LED hooked to B1 doesn't blink. (The circuit is simple: the five wires from the ICD2 programmer are hooked up. In addition, there is a 10k resistor from MCLR to Vdd and a 1K resistor hooked to B1 with an LED to ground - rocket science. I plan to use the internal oscillator.)
My guess is that I am missing one or more #fuse settings or something similarly newbie-ish. Would you please offer some suggestions to get this thing working.
Thanks!
gerry <at> pairofdocs <dot> net _________________ Gerald P. Roston |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Mar 09, 2007 5:31 pm |
|
|
1. You have two oscillator types in your #fuses statement: HS and INTRC
You should only have one.
2.You don't have a while() loop at the end of your program. Because of
this, the program will fall off the end of main() and execute the hidden
SLEEP instruction that CCS puts there, the PIC will go to sleep.
Try this program instead. It will blink an LED on pin B0.
Code: | #include <16F88.H>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=8000000)
void main()
{
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|