View previous topic :: View next topic |
Author |
Message |
erkankocakaya Guest
|
16F690 Problem |
Posted: Thu Feb 22, 2007 8:22 am |
|
|
My problem is I cant use PIN_C0 and PIN_C1 same time
my compiler 3.249 .what is wrong or missing in this program.Help me please
Code: |
void main()
{
do {
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
delay_ms(2000);
OUTPUT_LOW(PIN_C0);
OUTPUT_LOW(PIN_C1);
delay_ms(2000);
}while(true); |
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Feb 22, 2007 9:37 am |
|
|
Which PIC processor are you using? Odds are it is a PIC16 with the famous "read, modify, write" problem. Use the search function of this forum to get more info on this issue.
Try the program below, if it works you can be sure it is the RMW problem.
Code: | void main()
{
do
{
OUTPUT_HIGH(PIN_C0);
delay_ms(100);
OUTPUT_HIGH(PIN_C1);
delay_ms(2000);
OUTPUT_LOW(PIN_C0);
delay_ms(100);
OUTPUT_LOW(PIN_C1);
delay_ms(2000);
}while(true);
} |
|
|
|
erkankocakaya Guest
|
Thanks |
Posted: Thu Feb 22, 2007 1:36 pm |
|
|
PIC 16F690 I am using.When I use below code C0 and C1 pins dont high
only B4 and B6 light the leds
Why do you think?
Code: |
main()
{
OUTPUT_HIGH(PIN_C0)
delay_ms(250);
OUTPUT_HIGH(PIN_C0)
delay_ms(250);
OUTPUT_HIGH(PIN_C1)
delay_ms(250);
OUTPUT_HIGH(PIN_C1)
delay_ms(250);
OUTPUT_HIGH(PIN_B4)
delay_ms(250);
OUTPUT_HIGH(PIN_B4)
delay_ms(250);
OUTPUT_HIGH(PIN_B6)
delay_ms(250);
OUTPUT_HIGH(PIN_B6)
delay_ms(250);
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 22, 2007 11:56 pm |
|
|
There's a bug in the startup code for the 16F690 in PCM vs. 3.249.
Comparator #2 is turned on by mistake. That's why pins C0 and C1
don't work. You can fix this by adding the line of code shown in bold
below, at the start of your program:
Quote: |
void main()
{
setup_comparator(NC_NC_NC_NC);
while(1);
} |
|
|
|
|