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

delay interrupts rtcc inside main program...
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wwwglro



Joined: 03 Sep 2009
Posts: 17

View user's profile Send private message

PostPosted: Sun Sep 13, 2009 2:42 am     Reply with quote

Hello.
That code works but in a single click event the corresponding led lights for indefinite time.
When I try to modify to light for a few seconds (using delay_ms()), when I push another button, it doesn't do anything (until the delay is finished).
So is there a way to interrupt the delay_ms() function when I press another button?
Thank you.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 13, 2009 2:59 pm     Reply with quote

Post your code that uses Mark's driver.
(Don't post Mark's driver. I already know where it is).
wwwglro



Joined: 03 Sep 2009
Posts: 17

View user's profile Send private message

PostPosted: Wed Sep 16, 2009 6:59 am     Reply with quote

Hello.
My code actually, doesn't use Mark's code; it's like Mark's code (much simpler).
When I push a button, a led lights for 3 seconds.
When I push other button, another led starts to light (and the first stops lighting).
When I hold down the button, the led should light until the button is released.
My problem is that my code doesn't do that. When I release the button, the led stops lighting after three seconds not immediately.

I try to modify Mark's code for doing that, but when I insert a delay routine for led to light three seconds, in a single click event, when I push another button, the corresponding led doesn't start to light until the first one has stopped.

That's why I asked if is there a way to stop delay routine when the button is held down.

Thank you.
wwwglro



Joined: 03 Sep 2009
Posts: 17

View user's profile Send private message

PostPosted: Sun Sep 20, 2009 8:57 am     Reply with quote

Here is the code:
Code:

#include <16f84A.h>
#use delay(clock=4000000) //we have 3906 interupts per seconde
long bec0=1;
long bec1=1;

#int_rtcc
void clock_isr() {

bec0--;
bec1--;
if(bec0<1) bec0=1;
if(bec1<1) bec1=1;

if(bec0>1)
   output_high(pin_b0);
else
   output_low(pin_b0);

if(bec1>1)
   output_high(pin_b1);
else
   output_low(pin_b1);
}


void main()
{
set_rtcc(0);
setup_counters (RTCC_INTERNAL, RTCC_DIV_1);
enable_interrupts (INT_RTCC);
enable_interrupts(GLOBAL);

do {
  if(input(PIN_a0)==0) //the button 1
  {
    bec0=19530; //3906*5 seconde
    bec1=1;
  }

  if(input(PIN_a1)==0) //the button 2
  {
    bec1=19530; //3906*5 seconde
    bec0=1;
  }

} while(1);
}

It doesn't do the held button but only the 5 seconds led blinking when a button is pressed
Thank you.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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