??? 11/05/04 01:57 Read: times |
#80403 - SDCC input from single pin? |
Ok, this is ridiculously basic, but I have searched for several hours and can't find this.
I've prog'd in asm for quite some time, but wanted to try C - but I'm having a hard time trying to figure out how to interface an input pin... What I'm trying to do is just perform an if statement dependent upon the status of an input. For example: if(button) { blinkslow(); } else { blinkfast(); } Which should just return a 1 or 0 dependent upon the status of the button, right? I've also replaced "button" with "button==1", didn't help... I've tried two different ways of setting up the "button" - #define Trigger P3_2 which didn't work, and Trigger sbit at P3_2; which didn't either. The following asm works fine: jb P3.2,LEDSLOW call BLINKFAST jmp BLINKINDONE LEDSLOW: call BLINKFAST BLINKINDONE: Also, if you reverse the blink functions(in the C code), the results are the opposite, (as listed it always blinks slow, if you reverse them it always blinks fast.... Any insight? What am I doing wrong? Any good reference or example code for SDCC anyone can point me to? I found PLENTY on the compiler and stuff, but very little on the nuances of the syntax... Thanks! |