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

How can use temp_seconds

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



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

How can use temp_seconds
PostPosted: Thu Jan 19, 2012 9:30 am     Reply with quote

I can't understand how I can use temp_seconds in TIMER1_isr ?
Now I'm use like this ------
Code:

/*******************************************************  Timer1 Interrupt, executed every 10 ms
 *******************************************************/
#INT_TIMER1
void TIMER1_isr(void)
{
   // Increment time_elasped to keep track of ms
   time_elasped++;
   // Increment seconds variable if 1000 ms have passed
   
   if (time_elasped == 100)  // @ 1000 ms
   {
        seconds++;
        time_elasped = 0;
     
   }
   if (seconds != temp_seconds) // now (ch_3>=950)
      {
         odd_or_even = seconds % 2;
         // Even?  Yes
         if (odd_or_even == 0)
            output_high(L3);
         else
            output_low(L3);
      }
      if (seconds != seconds) // now (ch_3<950)
      {
            output_low(L3);
      }
   //Reset Timer 1
   set_timer1(60545);
   clear_interrupt(INT_TIMER1);   
}

/*******************************************************
 Reads Form AN3 ADC_Value for lod sence
********************************************************/
void Process_ch_3(void)
{
      if (ch_3<950)
{
      over_lod_flag = off;
      ol_counter_flag = off;
      seconds=seconds;
}
      if (ch_3>=950)
{
      seconds=temp_seconds;
      BlinkLED2();
     lcd_putc("\fOVER SENCE PLASE\n");
     lcd_putc(" REDUCE LOAD");  //
   delay_ms(500);
}
     if ( rest_sec=BLINK_SEC - temp_seconds);
{
      ol_counter_flag =on;
      rest_sec--;
      lcd_gotoxy(1,1);
      printf ( lcd_putc,"\fSECONDS LEFT %lu ",rest_sec);
      lcd_gotoxy(1,2);
      printf ( lcd_putc,"FOR OUTPUT CUT");
   delay_ms(500);
}

}

But temp_seconds sec not working.
I want if (ch_3>=950), then temp_seconds work. But it work every time [if (ch_3>=950) or if (ch_3<950) ].
pl help me ...
_________________
sahu
temtronic



Joined: 01 Jul 2010
Posts: 9174
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 19, 2012 10:24 am     Reply with quote

I can't see anywhere in these 'code segments' that you actually assign any value to the variable temp_seconds and I must assume you've declared it as an INT16 NOT the default of INT8.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Thu Jan 19, 2012 10:33 am     Reply with quote

This must be a joke or a homework assignment.
sahu77has answered his own question within the question itself.
There are no variable definitions.
There is an error in the third condition in the interrupt
if (seconds != seconds) // now (ch_3<950)

(ch_3>=950)
(ch_3<950)

What does != mean ?
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Thu Jan 19, 2012 11:23 am     Reply with quote

temtronic wrote:
I can't see anywhere in these 'code segments' that you actually assign any value to the variable temp_seconds and I must assume you've declared it as an INT16 NOT the default of INT8.

yes int16 temp_seconds ;
Code:
     if ( rest_sec=BLINK_SEC - temp_seconds);
{
      ol_counter_flag =on;
      rest_sec--;
      lcd_gotoxy(1,1);
      printf ( lcd_putc,"\fSECONDS LEFT %lu ",rest_sec);
      lcd_gotoxy(1,2);
      printf ( lcd_putc,"FOR OUTPUT CUT");
   delay_ms(500);
}

use here temp_seconds
_________________
sahu
temtronic



Joined: 01 Jul 2010
Posts: 9174
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 19, 2012 11:55 am     Reply with quote

You still have not shown how values are stored INTO temp_seconds only examples of it being used for some calculations.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Jan 19, 2012 5:13 pm     Reply with quote

checkout what WAYNE_ sez dude!!!

Code:

 if (seconds != seconds)


last time i checked seconds BETTER always ==seconds.
under what conditions will this branch be taken ??

if this was a lunch order in CCS C - you'd starve to death LOL
Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Jan 20, 2012 5:20 am     Reply with quote

There is also your other thread on this same RTC function where you never responded to. Very impolite.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Jan 20, 2012 7:12 am     Reply with quote

sahu77 wrote:
temtronic wrote:
I can't see anywhere in these 'code segments' that you actually assign any value to the variable temp_seconds and I must assume you've declared it as an INT16 NOT the default of INT8.

yes int16 temp_seconds ;
Code:
     if ( rest_sec=BLINK_SEC - temp_seconds);
{
      ol_counter_flag =on;
      rest_sec--;
      lcd_gotoxy(1,1);
      printf ( lcd_putc,"\fSECONDS LEFT %lu ",rest_sec);
      lcd_gotoxy(1,2);
      printf ( lcd_putc,"FOR OUTPUT CUT");
   delay_ms(500);
}

use here temp_seconds


that's not a declaration. That's a use.. in an IF... as an argument, not a destination.

Typically it's bad form to assign values in conditional statements. (I read somewhere).

Consider rewriting to use == for rest_sec's comparison...

and you still need a declaration of INT16 (or more likely unsigned int16) somewhere for temp_seconds.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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