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

timer1 steup

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







timer1 steup
PostPosted: Thu May 27, 2004 2:49 am     Reply with quote

Hiiii....

Can I setup & enable/disable Tİmer1 in an ISR (for example in #INT_EXT)
without any limitation ?

Thanks anybody who answers

The ISR is as follows:




#INT_EXT
void pass_fonk()
{

enable_interrupts(INT_TIMER1);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);

if(rise_edge){

rise_edge=FALSE;

set_timer1(0xFC17);

value_i=0;
value_o=0;
akim_s =0;
ort=0;

ext_int_edge(H_TO_L);
}
else
{
rise_edge=TRUE;

set_timer1(0xE4A7);

ext_int_edge(L_TO_H);

/* value_i=(value_i/ort) * 250.0/1023.0; //2.22
value_o=(value_o/ort) * 250.0/1023.0; //value_o=value_o/ort * 250.0/1023.0;
akim_s =(akim_s /ort) * 100.0/1023.0; */


_i++;
if(_i==50){


// if(TS==1) printf("\f500"); // sistem
// printf("\iVI:%U \oVO:%U \aA:%U " ,(unsigned)value_i, (unsigned)value_o, (unsigned)akim_s);

_i=0;
}
if(bb==1)

stb_fonk();

switch_fonk();
//}

sayac+=ort;

}

enable_interrupts(INT_TIMER1);


if(input(PIN_B0))
rise_edge=FALSE;


enable_interrupts(INT_EXT);


}
Ttelmah
Guest







Re: timer1 steup
PostPosted: Thu May 27, 2004 4:51 am     Reply with quote

hundil wrote:
Hiiii....

Can I setup & enable/disable Tİmer1 in an ISR (for example in #INT_EXT)
without any limitation ?

Thanks anybody who answers

The ISR is as follows:




#INT_EXT
void pass_fonk()
{

enable_interrupts(INT_TIMER1);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);

if(rise_edge){

rise_edge=FALSE;

set_timer1(0xFC17);

value_i=0;
value_o=0;
akim_s =0;
ort=0;

ext_int_edge(H_TO_L);
}
else
{
rise_edge=TRUE;

set_timer1(0xE4A7);

ext_int_edge(L_TO_H);

/* value_i=(value_i/ort) * 250.0/1023.0; //2.22
value_o=(value_o/ort) * 250.0/1023.0; //value_o=value_o/ort * 250.0/1023.0;
akim_s =(akim_s /ort) * 100.0/1023.0; */


_i++;
if(_i==50){


// if(TS==1) printf("\f500"); // sistem
// printf("\iVI:%U \oVO:%U \aA:%U " ,(unsigned)value_i, (unsigned)value_o, (unsigned)akim_s);

_i=0;
}
if(bb==1)

stb_fonk();

switch_fonk();
//}

sayac+=ort;

}

enable_interrupts(INT_TIMER1);


if(input(PIN_B0))
rise_edge=FALSE;


enable_interrupts(INT_EXT);


}

I'd do the actual 'setup' externally (you want to put as little code inside any ISR as possible). Also changing the value, the operating edge etc., will very probably result in the interrupt having been triggered, so I'd suggest setting all the values, then clearing the interrupt flag (the compiler now supports this), and then enabling the interrupt.

Best Wishes
hundil
Guest







timer and ISR
PostPosted: Thu May 27, 2004 6:34 am     Reply with quote

Hiii again....

I am definitely sure that there is no other interrupt occured in the INT_EXT ISR. (during execution of INT_EXT)

There are 3-4 different INTs, and most of routines are working fine.

My main routine is almost empty with

do{ }while(true)

I need much more variables to take them into the main routine

What about your suggestion ?

Best wishes

hundil
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