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

Interrupt won't be generated

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







Interrupt won't be generated
PostPosted: Tue May 20, 2003 7:28 am     Reply with quote

Hi there
My Timer0 Interrupt will never be generated. The interrupt service routine should increment the global variable 'ofl', and in my main routine, the variable will be displayed on a common lcd. But on my lcd, it shows always '000'.
If I set a breakpoint in my interrupt service routine, the program will never break there.
Here is my source:

#nolist
#include <c:\Programme\PICC\Devices\16f877.h>
#fuses HS, NOWDT, NOPROTECT, PUT, NOBROWNOUT, NOLVP
#use delay(clock=20000000)
#include <c:\Programme\PICC\Drivers\lcd.c>

unsigned int8 ofl;

#int_timer0
second() {
ofl++;
}

void main(void) {
int8 i = 0;
int16 ii;
lcd_init();
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
while(1)
{
i++;
lcd_gotoxy(1, 1);
printf(lcd_putc, "\%03U ", ofl);
delay_ms(500);
}
}


Can you help me?

Thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514589
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Interrupt won't be generated
PostPosted: Tue May 20, 2003 11:41 am     Reply with quote

:=Hi there
:=My Timer0 Interrupt will never be generated. The interrupt service routine should increment the global variable 'ofl', and in my main routine, the variable will be displayed on a common lcd. But on my lcd, it shows always '000'.
:=If I set a breakpoint in my interrupt service routine, the program will never break there.
-----------------------------------------------------------

I got it to work. I don't have a LCD on my test board,
so I removed that code, used RS-232 output instead.

Here is the output:
000 016 031 047 062 077 093 108 123 139 etc.

Also, I'm using a 8 MHz crystal, instead of 20 MHz.

If you can't make this work, then post your version
of the compiler. It's possible that your version
has a problem. I used PCM vs. 3.158.

<PRE>
#include "c:\Program Files\Picc\Devices\16F877.H"
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 8000000)
#use rs232(baud = 9600, xmit=PIN_C6, rcv = PIN_C7, ERRORS)
<BR>
<BR>
unsigned int8 ofl;
<BR>
#int_timer0
second()
{
ofl++;
}
<BR>
//===================
void main(void)
{
int8 i = 0;
<BR>
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
<BR>
while(1)
{
i++;
printf("\%03U ", ofl);
delay_ms(500);
}
}
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514598
Marcel Tschopp
Guest







Re: Interrupt won't be generated
PostPosted: Wed May 21, 2003 12:06 am     Reply with quote

Thank you for your fast response. I'm using PCM v3.110 with MPLAB 6.20 and ICD2

:=:=Hi there
:=:=My Timer0 Interrupt will never be generated. The interrupt service routine should increment the global variable 'ofl', and in my main routine, the variable will be displayed on a common lcd. But on my lcd, it shows always '000'.
:=:=If I set a breakpoint in my interrupt service routine, the program will never break there.
:=-----------------------------------------------------------
:=
:=I got it to work. I don't have a LCD on my test board,
:=so I removed that code, used RS-232 output instead.
:=
:=Here is the output:
:=000 016 031 047 062 077 093 108 123 139 etc.
:=
:=Also, I'm using a 8 MHz crystal, instead of 20 MHz.
:=
:=If you can't make this work, then post your version
:=of the compiler. It's possible that your version
:=has a problem. I used PCM vs. 3.158.
:=
:=<PRE>
:=#include "c:\Program Files\Picc\Devices\16F877.H"
:=#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
:=#use delay(clock = 8000000)
:=#use rs232(baud = 9600, xmit=PIN_C6, rcv = PIN_C7, ERRORS)
:=<BR>
:=<BR>
:=unsigned int8 ofl;
:=<BR>
:=#int_timer0
:=second()
:={
:=ofl++;
:=}
:=<BR>
:=//===================
:=void main(void)
:={
:=int8 i = 0;
:=<BR>
:=setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256);
:=enable_interrupts(INT_RTCC);
:=enable_interrupts(GLOBAL);
:=<BR>
:=while(1)
:= {
:= i++;
:= printf("\%03U ", ofl);
:= delay_ms(500);
:= }
:=}
:=</PRE>
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514616
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Interrupt won't be generated
PostPosted: Wed May 21, 2003 12:22 pm     Reply with quote

:=Thank you for your fast response. I'm using PCM v3.110 with MPLAB 6.20 and ICD2
:=
---------------------------------------------------------

I installed PCM vs. 3.110 and it still worked.

I suggest that you try to make my sample program
work with your development environment. Try to
make as few changes as possible to my program.
For example, don't use your LCD initially, but
use the RS232 interface to send the output to your PC.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514641
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