CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

turn high 2-3 port at the same time

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
takumi



Joined: 07 Mar 2009
Posts: 14

View user's profile Send private message

turn high 2-3 port at the same time
PostPosted: Wed Aug 04, 2010 12:37 am     Reply with quote

Code:

#define SW1 PIN_B0
#define SW2 PIN_C5
#define BUZZER PIN_D6
#define LED1 PIN_D7
#define LED2 PIN_E2
                           
void main(){
       
   while(1){   
      if(!input(SW1) && input(SW2)) output_high(LED1);
                                                     
      else if (input(SW1) && !input(SW2)) output_high(LED2);
                             
      else if(!input(SW1) & !input(SW2)){
       output_d(0b11000000);                   
       output_high(LED2);                                 
         }                       
                                       
      else {                       
         output_low(LED1); 
         output_low(LED2);           
         output_low(BUZZER);
         }
   }
                     
}

Hi all, is there any method to turn on both LED1 & Buzzer at the same time?

I have tried to use:
Code:

{
output_high(LED1); 
output_high(LED2);           
output_high(BUZZER);
}

But the simulation in Proteus shows the LED1 & BUZZER just blinking.
But if I used the code as below, both turn high:
Code:

{
output_d(0b11000000);
}

Why does this thing happen? Any idea? Please help.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Aug 04, 2010 1:54 am     Reply with quote

Search for previous threads about RMW (read-modify-write) issue.

In a short, it happens because you are overloading the pins, so that the output high level is below specified minimum input high value.
takumi



Joined: 07 Mar 2009
Posts: 14

View user's profile Send private message

PostPosted: Wed Aug 04, 2010 6:11 am     Reply with quote

tq.. found the solution already. Just add 330 resistor before the LED.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group