|
|
View previous topic :: View next topic |
Author |
Message |
Nikki Guest
|
Interrupt Problems |
Posted: Tue Oct 22, 2002 1:29 pm |
|
|
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 |
Posted: Tue Oct 22, 2002 1:36 pm |
|
|
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
|
Re: Interrupt Problems |
Posted: Tue Oct 22, 2002 1:51 pm |
|
|
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
|
Re: Interrupt Problems |
Posted: Tue Oct 22, 2002 1:57 pm |
|
|
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
|
Re: Interrupt Problems |
Posted: Tue Oct 22, 2002 2:24 pm |
|
|
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 |
Posted: Tue Oct 22, 2002 2:56 pm |
|
|
Thanks everyone for the answer!
Nikki
___________________________
This message was ported from CCS's old forum
Original Post ID: 8105 |
|
|
|
|
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
|