Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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!

List of 32 messages in thread
TopicAuthorDate
SDCC input from single pin?            01/01/70 00:00      
   RE: SDCC input from single pin?            01/01/70 00:00      
      RE: SDCC input from single pin?            01/01/70 00:00      
         RE: SDCC input from single pin?            01/01/70 00:00      
            RTFM            01/01/70 00:00      
               RE: RTFM            01/01/70 00:00      
      RE: SDCC input from single pin?            01/01/70 00:00      
         RE: SDCC input from single pin?            01/01/70 00:00      
         some day you will go nuts SDCCor not            01/01/70 00:00      
   RE: SDCC input from single pin?            01/01/70 00:00      
      RE: SDCC input from single pin?            01/01/70 00:00      
   RE: SDCC input from single pin?            01/01/70 00:00      
   RE: SDCC input from single pin?            01/01/70 00:00      
   What does the manual say?            01/01/70 00:00      
      What the manual says            01/01/70 00:00      
   RE: SDCC input from single pin?            01/01/70 00:00      
      RE: SDCC input from single pin?            01/01/70 00:00      
         RE: SDCC input from single pin?            01/01/70 00:00      
            RE: SDCC input from single pin?            01/01/70 00:00      
               RE: SDCC input from single pin?            01/01/70 00:00      
         RE: SDCC input from single pin?            01/01/70 00:00      
            RE: SDCC input from single pin?            01/01/70 00:00      
            Charles Bannister            01/01/70 00:00      
            RE: P3_2            01/01/70 00:00      
            Criticisms of Keil            01/01/70 00:00      
               RE: Criticisms of Keil            01/01/70 00:00      
            RE: SDCC input from single pin?            01/01/70 00:00      
   Actually... My fault :)            01/01/70 00:00      
      Steady on...!            01/01/70 00:00      
   RE: SDCC input from single pin?            01/01/70 00:00      
      RE: SDCC input from single pin?            01/01/70 00:00      
      RE: User error            01/01/70 00:00      

Back to Subject List