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 support@ccsinfo.com

Want pin high for a moment

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







Want pin high for a moment
PostPosted: Fri Mar 31, 2006 12:44 am     Reply with quote

hello,
Could anyone tell me how to make pin D high just for a moment/second when "Measuring..." is being displayed.The pin D0 should be high when mechanical switch is pressed.I tried using Output_high(PIN_D0) with the measuring display printf.The problem is this will keep pin DO high till the time 8 bit input is received.

I want D0 high just for a moment when mechanical switch is pressed and then low immediately.

Help me.
Emon

CODE::
void main()
{ int Num_output=10;

int8 result;
int8 value;
int top;
port_b_pullups(TRUE);

lcd_init();
delay_ms(1000);
lcd_init();


while(1)
{
value = input_b();

if(value != 255)
{

if(value & 0x80)
{
printf(lcd_putc,"\fERROR!!\n");
delay_ms(1000);
}
else
{result = value & 0x7F;
printf(lcd_putc,"\fDistance:\n");
printf(lcd_putc,"%u",result);
delay_ms(1000);
}

}
else
{

printf(lcd_putc,"\fMeasuring...\n");
delay_ms(1000); //I want pin DO high just for a moment when when mechanical switch pressed
}

}//while1
}//main
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Mar 31, 2006 7:24 am     Reply with quote

Try this
Code:

else
{
  printf(lcd_putc,"\fMeasuring...\n");
  output_high(PIN_D0)
  delay_ms(500);
  output_low(PIN_D0)
  delay_ms(500);
}


emon
Guest







RE:
PostPosted: Fri Mar 31, 2006 9:45 pm     Reply with quote

thanks mark.
The problem is the code you wrote will keep making D0 high and low till PORT B gets input.
I want DO to go high just once when switch is pressed.
Do i use some interrupt?Please guide me
emon
Guest







help
PostPosted: Sat Apr 01, 2006 10:40 am     Reply with quote

can anyone help??
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sat Apr 01, 2006 10:57 am     Reply with quote

A couple of suggestions:

Provide more information. You mention a switch being depressed but your code doesn't give any indication of a switch being implemented and you only briefly mention it in your post. Even a section of pseudo-code would help the members of the forum understand what you're trying to accomplish.

Provide a complete program listing.

Insert your code using the 'code' feature.

If you're not getting the help you expect, you may be approaching the request in the wrong way. Mark's code snippet does exactly what you requested.

I think if you heed the previous advice you'll have people jumping at the opportunity to help.

Good luck,

John
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sat Apr 01, 2006 11:08 am     Reply with quote

It also sounds like a school project which I am not going to write your program for you.
tavioman



Joined: 22 Feb 2006
Posts: 65

View user's profile Send private message

PostPosted: Sun Apr 02, 2006 6:08 am     Reply with quote

Try with some TIMER interrupt.
start timer........
led high............
timer interrupt..
led low.............

This shoul be very simple and fast.
If the timer overflow it's smaller than one second try with a remainder.
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