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 Problems

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







Interrupt Problems
PostPosted: Tue Oct 22, 2002 1:29 pm     Reply with quote

3.116 PIC16F628

I wonder if someone could enlighten me as to why as soon as I enable interrupts for any specific timer overflow, the interrupt is executed straight away.

I'm doing something like this:

setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
set_timer1(0xCF2C);// 100ms delay
enable_interrupts(int_timer1); // INT_TIMER1 execute here

Do I need to clear some flags to fix this?

On another subject. I'm trying to debug some code using MPLAB Simulator and have 16 bit pointers enabled in CCS, but the register and watch windows show a wrap around. I have a register at 0x7F and when its contents is changed, the contents of 0xFF and 0x17F also show a change. Is this correct for MPLAB?

Thanks,

Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 8093
Nikki
Guest







Re: Interrupt Problems
PostPosted: Tue Oct 22, 2002 1:36 pm     Reply with quote

Ignore my second question. The datasheet says "accesses 70h-7fh" for these locations, so I understand the reason.

Nikki

:=On another subject. I'm trying to debug some code using MPLAB Simulator and have 16 bit pointers enabled in CCS, but the register and watch windows show a wrap around. I have a register at 0x7F and when its contents is changed, the contents of 0xFF and 0x17F also show a change. Is this correct for MPLAB?
___________________________
This message was ported from CCS's old forum
Original Post ID: 8094
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

Re: Interrupt Problems
PostPosted: Tue Oct 22, 2002 1:51 pm     Reply with quote

Try this. I would suggest that you always disable the timer before changing its value:

setup_timer_1(T1_DISABLED);
PIR1.TMR1IF = 0 // this assumes you have a structure defined or something like bit_clear(PIR1, TMR1IF) or bit_clear(PIR1,0)
set_timer1(0xCF2C);// 100ms delay
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
enable_interrupts(int_timer1); // INT_TIMER1 execute here

Regards,
Mark

:=3.116 PIC16F628
:=
:=I wonder if someone could enlighten me as to why as soon as I enable interrupts for any specific timer overflow, the interrupt is executed straight away.
:=
:=I'm doing something like this:
:=
:=setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
:=set_timer1(0xCF2C);// 100ms delay
:=enable_interrupts(int_timer1); // INT_TIMER1 execute here
:=
:=Do I need to clear some flags to fix this?
:=
:=On another subject. I'm trying to debug some code using MPLAB Simulator and have 16 bit pointers enabled in CCS, but the register and watch windows show a wrap around. I have a register at 0x7F and when its contents is changed, the contents of 0xFF and 0x17F also show a change. Is this correct for MPLAB?
:=
:=Thanks,
:=
:=Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 8095
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

Re: Interrupt Problems
PostPosted: Tue Oct 22, 2002 1:57 pm     Reply with quote

Try this. I would suggest that you always disable the timer before changing its value:

setup_timer_1(T1_DISABLED);
PIR1.TMR1IF = 0 // this assumes you have a structure defined or something like bit_clear(PIR1, TMR1IF) or bit_clear(PIR1,0)
set_timer1(0xCF2C);// 100ms delay given a clock of 4MHz
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
enable_interrupts(int_timer1); // INT_TIMER1 execute here

Regards,
Mark

:=3.116 PIC16F628
:=
:=I wonder if someone could enlighten me as to why as soon as I enable interrupts for any specific timer overflow, the interrupt is executed straight away.
:=
:=I'm doing something like this:
:=
:=setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
:=set_timer1(0xCF2C);// 100ms delay
:=enable_interrupts(int_timer1); // INT_TIMER1 execute here
:=
:=Do I need to clear some flags to fix this?
:=
:=On another subject. I'm trying to debug some code using MPLAB Simulator and have 16 bit pointers enabled in CCS, but the register and watch windows show a wrap around. I have a register at 0x7F and when its contents is changed, the contents of 0xFF and 0x17F also show a change. Is this correct for MPLAB?
:=
:=Thanks,
:=
:=Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 8096
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Interrupt Problems
PostPosted: Tue Oct 22, 2002 2:24 pm     Reply with quote

When you enable the interupt the timer has already overflowed and set the interupt bit. Clear the interupt bit (overflow bit) before enabeling the interupt.


:=3.116 PIC16F628
:=
:=I wonder if someone could enlighten me as to why as soon as I enable interrupts for any specific timer overflow, the interrupt is executed straight away.
:=
:=I'm doing something like this:
:=
:=setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
:=set_timer1(0xCF2C);// 100ms delay
:=enable_interrupts(int_timer1); // INT_TIMER1 execute here
:=
:=Do I need to clear some flags to fix this?
:=
:=On another subject. I'm trying to debug some code using MPLAB Simulator and have 16 bit pointers enabled in CCS, but the register and watch windows show a wrap around. I have a register at 0x7F and when its contents is changed, the contents of 0xFF and 0x17F also show a change. Is this correct for MPLAB?
:=
:=Thanks,
:=
:=Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 8100
Nikki
Guest







Re: Interrupt Problems
PostPosted: Tue Oct 22, 2002 2:56 pm     Reply with quote

Thanks everyone for the answer!

Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 8105
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