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

Why would #int_rda stop responding?

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 01, 2007 11:21 pm     Reply with quote

When the reset_cpu() function is called in a 16F chip, it jumps to
address 0x0000. The stack is 8-deep and it's circular. The stack
pointer is a modulo-8 counter. The initial value of the stack pointer
at the start of a program doesn't matter.

In the program shown below, a Timer1 interrupt occurs about 524 ms
after the start of the program. Inside the isr, the reset_cpu() function
is called. This function will jump to address 0x0000 and thus restart
the program, while leaving the return address on the stack. No hardware
reset is performed by the PIC.

The program runs OK. It restarts every time and there's no problem
with the stack. Here's the output of the program:
Quote:

ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
ABCDEFT
etc.


Here's the test program:
Code:

#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#int_timer1
void timer1_isr(void)
{
putc('T');
putc('\n');
putc('\r');
reset_cpu();
}

//===============================
void main()
{
int8 value;

// Setup Timer1 to interrupt every 524 ms (with 4 MHz crystal).
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
set_timer1(0x0000);
clear_interrupt(INT_TIMER1);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);

value = 'A';

while(1)
  {
   putc(value);
   value++;
   delay_ms(100);
  }
}
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