A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
I'm a novice working with 16f628a - sr_gamer - May 1 18:15:08 2009
I've been searching around for examples, but learning is slow going.
At the moment I'm trying to program a 16f628a to light one LED for a controlled length of
time and then light another for a controlled length of time and then the program should
end.
This is just a learning exercise. I'm using the HiTech C compiler with MPLAB and
programming with a PICkit2.
When I run the code that I've included below, both LEDs come on and stay on.
Here is my code:
#include
__CONFIG(INTCLK & WDTDIS & PWRTDIS & BORDIS & LVPDIS & UNPROTECT);
void main( void )
{
TRISB = 0b00000000; //set port B pins as outputs
PORTB = 0b00000010; //turn on LED at pin 7 RB1
_delay(1000); //Delay
PORTB = 0b00000001; //turn on LED at pin 6 RB0
_delay(1000);
}
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: I'm a novice working with 16f628a - demolitron - May 4 18:55:27 2009
Hello,
Looking at your code, first off I always put an infinite loop at the end of the program.
There isn't an "end" command. Instead the program counter continues to run until it
overflows back to 0. Then your program runs again.
I usually add a while(1); statement at the end of main() to send it off into a nice
coma.
Also, the software simulator is your friend. I sure do use it a lot. Try removing the
delay statements and step through the code while using the watch window to look at PORTB.
I've forgotten little things, like a CCP peripheral forcing some ports to be inputs,
etc... that drove me mad before I found the answer.
--- In p...@yahoogroups.com, "sr_gamer"
wrote:
>
> I've been searching around for examples, but learning is slow going.
>
> At the moment I'm trying to program a 16f628a to light one LED for a controlled length
of time and then light another for a controlled length of time and then the program should
end.
>
> This is just a learning exercise. I'm using the HiTech C compiler with MPLAB and
programming with a PICkit2.
>
> When I run the code that I've included below, both LEDs come on and stay on.
>
> Here is my code:
>
> #include __CONFIG(INTCLK & WDTDIS & PWRTDIS & BORDIS & LVPDIS & UNPROTECT);
>
> void main( void )
> {
> TRISB = 0b00000000; //set port B pins as outputs
>
> PORTB = 0b00000010; //turn on LED at pin 7 RB1
> _delay(1000); //Delay
>
> PORTB = 0b00000001; //turn on LED at pin 6 RB0
> _delay(1000);
> }
>
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )