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

Timer 1 behaving strange

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



Joined: 19 Jan 2004
Posts: 5

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

Timer 1 behaving strange
PostPosted: Mon Jan 19, 2004 6:56 am     Reply with quote

Hi,

Could someone help me white this problem #int timer_1.

this is the code. i have a questio about.
when leaving out the two line markt with **, the timer 1 give an interrupt every 16uS (see set_timer1 at FF90). When insert the line markt with ** the code works great and give a correct interupt.
I do not know what cousing the problem, could someone help to explane why behaving so strange.

thanks

Frans n

Code:

#include "C:\Program Files\PICC\progam\dmx.h"


#int_RDA
RDA_isr()
{

Dmx_data = getc();

if (bit_test(RS232_ERRORS,1) == 1) //is er een overflow oerr test
{

}
if (bit_test(RS232_ERRORS,2) == 1) //break detect FERR bit test
{
disable_interrupts(INT_RDA);
setup_timer_1(T1_INTERNAL); **
set_timer1(0xFF90);
enable_interrupts(INT_TIMER1);

output_low(PIN_B2);
delay_cycles( 2 );
output_high(pin_B2);



}

else
{
if (Break_true == true) // break is true
{
// output_low(PIN_B2);
// delay_cycles( 2 );
// output_high(pin_B2);

Break_true = false;

}
}

}


#int_TIMER1
TIMER1_isr()
{
disable_interrupts(INT_TIMER1);
setup_timer_1(T1_DISABLED);**

output_low(PIN_B2);
delay_cycles( 2 );
output_high(pin_B2);

Break_true = true;
enable_interrupts(INT_RDA);
}



void main()
{

//int8 Dmx_data;
Break_true = false;

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_INTERNAL);
setup_timer_2(T2_DISABLED,100,1);
disable_interrupts(INT_TIMER1);
// enable_interrupts(INT_TIMER1);
enable_interrupts(INT_RDA);
enable_interrupts(global);


while(TRUE);


}
neil



Joined: 08 Sep 2003
Posts: 128

View user's profile Send private message

Could be this...
PostPosted: Mon Jan 19, 2004 7:39 am     Reply with quote

Hello, firstly, your setup_timer1 command seems incomplete, you are not setting up the prescaler. The line should be something like:
Code:
setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_4 );
You will only need to setup timer 1 once, unless you wish to change the prescaler rate.

Secondly, there is no need to disable and re-enable the interrupts and the timer when inside the ISR. This will cause problems. I know that with some architectures this is common practise, but the pic handles interrupts differently. I ran into this problem a while ago. See this post: http://www.ccsinfo.com/forum/viewtopic.php?t=16799&highlight=

Look at the 3rd post down from RJ Hamlett. This explains the problem you seem to be having!

Hope this helps!
Neil.
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