View previous topic :: View next topic |
Author |
Message |
shybyl
Joined: 28 Sep 2010 Posts: 1
|
problem with changing OUTPUT ports |
Posted: Tue Sep 28, 2010 4:54 pm |
|
|
I'm new in pic programing and so I get sample source from here to dim led... but I do something wrong.. the pin stays HIGH all the time.
Can someone correct this source?
The source is:
Code: |
#INCLUDE <16F684.h>
#USE DELAY (CLOCK=4000000)
#FUSES INTRC_IO,NOWDT,NOPROTECT,NOPUT
void main(){
set_tris_a(1);
set_tris_c(0);
while(1){
output_high(PIN_C4);
delay_ms(1000);
output_low(PIN_C4);
delay_ms(1000);
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 29, 2010 11:25 am |
|
|
Delete the TRIS statements. You don't need them. The compiler will set
the TRIS.
What is your compiler version ? It's given at the top of the .LST file,
which will be in your project directory.
How are you testing this ? In Proteus, or in hardware ? Have you ever
made this PIC do anything ? Is this your first PIC project ? Do you
have a pull-up resistor on the MCLR pin ? Etc. |
|
|
W4GNS
Joined: 28 Sep 2010 Posts: 14 Location: Virginia, USA
|
works here |
Posted: Wed Sep 29, 2010 7:24 pm |
|
|
I tried your program with only changing the 16f to a 18f2520 as my compiler is resriticted to 18f parts, and changed the delay from 1000 to 10, and all was fine. If you're using a software simulator to test your code 1000 delay will take forever, so drop delay to 10 and you should see the blinky. and remember to change the delay back to 1000 if you try it in real hardware. |
|
|
|