View previous topic :: View next topic |
Author |
Message |
EE Guest
|
what wrong |
Posted: Fri May 22, 2009 11:47 am |
|
|
Code: | #include <18F4550.h>
#fuses HS,NOWDT,NOPUT,NOPROTECT
#use delay(clock=20000000)
#define s1 PIN_B1
#define s2 PIN_B2
void main()
{
while(1)
{
output_low(PIN_D7);
while(input(s1))
{
while(input(s2))
{
output_high(PIN_D7);
}
}
while(!input(s2))
{
output_low(PIN_D7);
}
}
} | This is my simple code to test my mcu. This code is waiting for logic high to pin_b1 and pin_b2 . But when I use this code the mcu pin_d7 go to high, but pin_b1 and pin_b2 are logic low. Why ??? |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri May 22, 2009 1:50 pm |
|
|
You are missing to NOLVP fuse - are you sure the PIC is not being help in programming mode? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
apcaye
Joined: 22 May 2009 Posts: 29 Location: Brazil
|
|
Posted: Mon May 25, 2009 2:50 pm |
|
|
Have you initialized the TRISB and TRISD registers? They indicate whether a pin is an input or an output. Do you have a pull-up or pull-down resistor connected to pins B1 and B2? If there is nothing connected to these pins, they can assume any value (0 or 1).
Regards,
Adriano. |
|
|
|