|
|
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 10, 2007 5:34 pm |
|
|
You don't need to set fixed i/o mode or TRIS. Just let the compiler
handle it. If you use the CCS i/o functions, the compiler will put in
code to properly handle the TRIS. You don't even have to think about it.
Here's a simple test program that toggles Pin B0. I specified the NOMCLR
fuse, because it's possible that you forgot to put a pull-up resistor on
the MCLR pin. With the NOMCLR fuse, this won't matter. The PIC will
still run the program even without the MCLR pull-up.
If it doesn't work, I would suspect your programmer, or maybe you
don't have a crystal and its capacitors properly connected to the PIC.
Code: |
#include <16F628A.h>
#fuses HS, NOWDT, PUT, NOLVP, NOMCLR
#use delay(clock=20000000)
//==========================
void main()
{
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Tue Dec 11, 2007 10:20 am |
|
|
In case your crystal might not be functioning properly, you could try using the internal oscillator to see if it works.
Code: | #include <16F628A.h>
#FUSES NOWDT
#FUSES PUT
#FUSES NOMCLR
#FUSES NOLVP
#FUSES INTRC_IO
#use delay(clock=4000000)
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator(OSC_4MHZ);
while(1)
{
output_b(0x00);
delay_ms(500);
output_b(0xFF);
delay_ms(500);
}
}
|
Ronald |
|
|
|
|
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
|