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

interrupt problem in 16F877A

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



Joined: 30 Mar 2010
Posts: 21

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

interrupt problem in 16F877A
PostPosted: Tue May 04, 2010 1:05 am     Reply with quote

Hai All,

I am using 16F877A in my project. I use UART, LCD and timer1.
If I enable timer1 then the main program doesn't work. If I disable
global interrupt then the main program works but timer1 doesn't work.

How to handle this ?

My interrupt code: it pops for every 500uSec.
Code:

#int_timer2                         
void clock_isr()
{
reader_count--;

if(reader_count == 0)
  {
   reader_count = 40;
   output_toggle(pin_C2);
  }

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Tue May 04, 2010 2:40 am     Reply with quote

You don't show the interrupt, and timer setups, but the obvious comment is 'which timer are you using'. You show a handler for timer2, but talk about enabling timer1. If you enable an interrupt without a handler, the code _will_ fail.

Best Wishes
balaji



Joined: 30 Mar 2010
Posts: 21

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

timer1 code
PostPosted: Tue May 04, 2010 3:55 am     Reply with quote

Now i identified the problem like this. when i use timer1 and ADC, timer1 works.(interupt at 500mS) whereas main loop and UART doesn`t work. my crystal frequency is 4MHz. Increasing the crystal to 12MHz shall solve the problem???

My timer1 code:
#int_timer1
void clock_isr()
{
disable_interrupts(int_timer1);
output_toggle(pin_C2);
enable_interrupts(int_timer1);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Tue May 04, 2010 4:55 am     Reply with quote

You need to post the other code, as I said before. Generate the smallest program that initialises the chip, and shows the problem. You may well find that doing show tells you what is wrong.

There is nothing 'wrong' with the interrupt code as posted (though you don't need to disable and enable the interrupts, the hardware does this automatically for you), _but_ the most likely problem is that your timer interval is so short that the processor is never getting out of the interrupt.

We can't tell, without seeing the timer setup code.

Best Wishes
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