View previous topic :: View next topic |
Author |
Message |
sahu77
Joined: 08 Sep 2011 Posts: 202
|
How can use temp_seconds |
Posted: Thu Jan 19, 2012 9:30 am |
|
|
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: 9238 Location: Greensville,Ontario
|
|
Posted: Thu Jan 19, 2012 10:24 am |
|
|
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
|
|
Posted: Thu Jan 19, 2012 10:33 am |
|
|
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
|
|
Posted: Thu Jan 19, 2012 11:23 am |
|
|
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: 9238 Location: Greensville,Ontario
|
|
Posted: Thu Jan 19, 2012 11:55 am |
|
|
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
|
|
Posted: Thu Jan 19, 2012 5:13 pm |
|
|
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
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Jan 20, 2012 5:20 am |
|
|
There is also your other thread on this same RTC function where you never responded to. Very impolite. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Fri Jan 20, 2012 7:12 am |
|
|
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 |
|
|
|