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

Can't get interrupts to fire on PIC16F1823

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



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

Can't get interrupts to fire on PIC16F1823
PostPosted: Tue Aug 30, 2016 12:45 pm     Reply with quote

New PIC for me, but i can't seem to get any timer interrupt to work! Wow, simple right?

PCWH 5.062
PIC16F1823 ON STABLE ELECTRICAL DESIGN (MULTIPLE BOARDS)

Simple code (right out of CCS Examples):
Code:

#include <16F1823.h>
#use Delay(internal=8000000)
#define HIGH_START 114
byte seconds, high_count;
#INT_Timer0

clock_isr() {
   if(--high_count==0) {
   delay_us(1);
   }
}

main() {
   high_count=HIGH_START;
   set_rtcc(0);
   setup_counters(RTCC_INTERNAL, RTCC_DIV_1);
   enable_interrupts(INT_Timer0);
   enable_interrupts(GLOBAL);

   while(TRUE);
}


Timer0 interrupt never fires. high_count stays at 114 after minutes. Have also written routines using other timers with same results-no interrupts. Am I losing my mind? Anyone see an issue? Have never had any problems with simple interrupts before.

Thanks!
JerryR



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

Solved--but still puzzled
PostPosted: Tue Aug 30, 2016 2:38 pm     Reply with quote

Well, kinda solved the issue. Consistently interrupts work using ICD3, but consistently does not work using a PICKit3 debugger. Still interested in knowing why.

Thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 30, 2016 4:52 pm     Reply with quote

Post your test procedure and environment. Are you running this test
in Debug or Release mode ? Are you using Debug Animate mode ?
What's your compiler version ? Are you using MPLAB 8.92 or MPLAB X
and what version ?

My guess is you are running in Debug mode, because I don't see any
code that toggles a pin so that you could put a scope on it.
JerryR



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

PostPosted: Tue Aug 30, 2016 6:01 pm     Reply with quote

Hi PCM:

Compiler version 5.062, MPLab 8.92, used PicKit3 and ICD3 in Debug mode and set breakpoints at both points inside ISR. Also, variable high_count never changed values after minutes. Have never used animate.

Never entered ISR using PicKit3, ICD3 worked well and resumed code development with no issues. Three custom-designed targets all are stable and good hardware. Repeated results back and forth between PicKit3 and ICD3. I'll try using my RealICE tomorrow just for curiosity.

Thanks for your interest.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 02, 2016 6:16 am     Reply with quote

At first I tried it with your program and breakpoints in the isr didn't work.
Then...
I didn't like your program so I modified it to the way I would write a
program. Then it worked. Very Happy Lol. I am loving this.

I set MPLAB v8.92 to compile in Debug mode, compiled the program,
and burned it into the 16F1823. Then I clicked to the left of the
output_toggle(PIN_C0) line in the source code to put a red breakpoint on
it. Then I clicked the "run" arrow in the MPLAB toolbar. It stops with the
cursor on the output_toggle(PIN_C0) line. I'm running this on the
Microchip Low Pin Count board, so it toggles the LED on Pin C0 each time
I click run. It's working great. This was tested with vs. 5.061.
Code:

#include <16F1823.h>
#fuses INTRC_IO, NOWDT
#use delay(clock=500KHZ)

#INT_TIMER0
void clock_isr()
{
output_toggle(PIN_C0);  // Put a breakpoint on this line with Pickit 3
}

//======================
void main()
{
output_low(PIN_C0);

set_timer0(0);
setup_timer_0(T0_INTERNAL | T0_DIV_256);  // Blink LED at ~ 1 Hz
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);

while(TRUE);
}
 


Last edited by PCM programmer on Fri Sep 02, 2016 6:22 am; edited 1 time in total
JerryR



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

PostPosted: Fri Sep 02, 2016 6:22 am     Reply with quote

Hi PCM:

Yes, interrupt working well now after burning code into target. Also worked while debugging with a ICD3 and RealICE emulators. Interrupt never fires while debugging with a PICKit3. Crazy! Anyway I moved ahead and finished the project.

As usual, thanks for your interest in the issue! All the best.
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