View previous topic :: View next topic |
Author |
Message |
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
input_state() |
Posted: Tue Jun 05, 2012 11:35 am |
|
|
Why level do not become '1'?
It shows me only LEVEL = 0
Code: |
#include <18F2520.h>
#fuses NOWDT,NOMCLR,intrc
#use delay(internal=8M)
#use rs232(baud=9600, xmit=PIN_a1,rcv=PIN_a2)
void main()
{
while (true)
{
int level;
output_high(pin_a0);
delay_ms(500);
level=input_state(pin_a0);
printf("\fLEVEL = %d",level);
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 05, 2012 11:37 am |
|
|
Don't declare local variables (such as 'level') in the middle of code. Put
them at the start of the function. |
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Tue Jun 05, 2012 1:22 pm |
|
|
I'm so sorry I lose your time. The mistake was all mine. My code is for 18f2520 and I had test it on 18f2431. I don't know how the **** display works properly and some other functions don't. So the problem was solved!
Thank you anyway! |
|
|
|