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

PIC18F452 / 458 Global Interrupt

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







PIC18F452 / 458 Global Interrupt
PostPosted: Sat Apr 05, 2003 11:42 am     Reply with quote

I'm using PCH V3.126. I need to generate an interrupt from the RTCC.

unsigned char Update = 1;

byte INTCON = 0x0FF2; //Give us access to intcon register
#int_rtcc
void RTCC_ISR
{ Update = 1; }

void main
{
....
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_BY_16);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);

while (1)
{
INTCON |= 0xC0; //<-If I force GIE set, its working
if (Update)
{
Update = 0;
... do something
}
}
}

This code is not working and should be working. I've looked at the code generated and it SHOULD be working but for some unknown reasons, GIE bit get cleared. If I set GIE at the beginning of the loop its ok but this is not a useable solution.

I know there are somes funny things about the 18F series interrupts. I would appreciate any help

Eric Girard
___________________________
This message was ported from CCS's old forum
Original Post ID: 13443
Mirko
Guest







Re: PIC18F452 / 458 Global Interrupt
PostPosted: Mon Apr 07, 2003 8:35 am     Reply with quote

I test youre program, and for me is OK. I used ( PIC 18F458 an PCWH 3.13)
When I download this firmware the microcontroller print "...HI..." every 1 second +/-.

Hi Mirko

********************************************************
#include <18F458.h>
#use delay(clock=4000000)
#fuses XT,NOWDT,WDT1
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)


int Update=0;

#int_RTCC
RTCC_isr() {
Update=1;
}



void main() {

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_16);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(FALSE);

enable_interrupts(INT_RTCC);
enable_interrupts(global);

while (1) {
if (Update) {
update=0;
printf("...HI...");
}
}
}

********************************************************



:=I'm using PCH V3.126. I need to generate an interrupt from the RTCC.
:=
:=unsigned char Update = 1;
:=
:=byte INTCON = 0x0FF2; //Give us access to intcon register
:=#int_rtcc
:=void RTCC_ISR
:={ Update = 1; }
:=
:=void main
:={
:= ....
:= setup_timer_0(RTCC_INTERNAL | RTCC_DIV_BY_16);
:= enable_interrupts(INT_RTCC);
:= enable_interrupts(GLOBAL);
:=
:= while (1)
:= {
:= INTCON |= 0xC0; //<-If I force GIE set, its working
:= if (Update)
:= {
:= Update = 0;
:= ... do something
:= }
:= }
:=}
:=
:=This code is not working and should be working. I've looked at the code generated and it SHOULD be working but for some unknown reasons, GIE bit get cleared. If I set GIE at the beginning of the loop its ok but this is not a useable solution.
:=
:=I know there are somes funny things about the 18F series interrupts. I would appreciate any help
:=
:=Eric Girard
___________________________
This message was ported from CCS's old forum
Original Post ID: 13461
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