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

PC incrementing over the Maximum PC address (SOLVED)

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



Joined: 06 Feb 2006
Posts: 468
Location: Bali

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

PC incrementing over the Maximum PC address (SOLVED)
PostPosted: Mon Aug 28, 2017 5:58 am     Reply with quote

Hi

The program below works OK in the MPLAB simulator but at the first time it gets to a break poit, the compiler is writing:
Quote:
CORE-W0014: Halted due to PC incrementing over the Maximum PC address and wrapping back to Zero

When it gets to the break point again or to other break points, the sentence don't appear again.
Code:
/////////////////////////////////////////////////////////////////////
//CCS PCM C Compiler, Version 5.062, xxxxx 
//PIC12F675 or PIC12F629 microcontroller
/////////////////////////////////////////////////////////////////////
#include <12F675.h>
#device ADC=8
#FUSES INTRC_IO,NOWDT,BROWNOUT,NOPROTECT
#use delay(internal=4MHz)
/////////////////////////////////////////////////////////////////////
#define flashled PIN_A5
int flashledCNT=0;
int timer1startCNT=0;
short onCNTstartF=0;
short eventF=0;
short toggleA2timeF=0;
short eventA3value=0;
short eventA4value=0;
/////////////////////////////////////////////////////////////////////
#INT_TIMER1
void  TIMER1_isr(void)
{
   set_TIMER1(15536);
   flashledCNT++;
   if(flashledCNT>=10)
   {
      flashledCNT=0;
      output_toggle(flashled);
   }
   timer1startCNT++;
   if((timer1startCNT>=20)&&(toggleA2timeF==1))//PIN_A toggle 1 second
   {
      disable_interrupts(INT_TIMER0);
      output_low(PIN_A2);//RFTX PWR OFF
      toggleA2timeF=0;   
   }
   if(timer1startCNT>=200)//flash LED 10 seconds
   {
      timer1startCNT=0;
      disable_interrupts(INT_TIMER1);//stops flash LED
      onCNTstartF=0;   
      eventF=0;   
   }
}
/////////////////////////////////////////////////////////////////////
#INT_TIMER0
void  TIMER0_isr(void)
{
   output_toggle(PIN_A1);//output to the RFTX data pin
}
/////////////////////////////////////////////////////////////////////
#INT_RA
void  RA_isr(void)
{
   delay_cycles(1);//for test only
   if((input(PIN_A3))||(input(PIN_A4)))
   {
      eventA3value=input(PIN_A3);//for test only
      eventA4value=input(PIN_A4);//for test only
      eventF=1;
      toggleA2timeF=1;
      enable_interrupts(INT_TIMER0);
      enable_interrupts(INT_TIMER1);
      output_high(PIN_A2);//RFTX ON      
   }
   else
   {
      eventA3value=input(PIN_A3);//for test only
      eventA4value=input(PIN_A4);//for test only
      delay_cycles(1);//for test only
   }
}
/////////////////////////////////////////////////////////////////////
#ZERO_RAM
/////////////////////////////////////////////////////////////////////
void main()
{
   PORT_A_PULLUPS(0b011000);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8|RTCC_8_BIT);//2.0 ms overflow
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);//65 ms overflow
   enable_interrupts(INT_TIMER1);
   onCNTstartF=1;
   toggleA2timeF=1;
   enable_interrupts(INT_TIMER0);
   enable_interrupts(INT_RA);
   enable_interrupts(GLOBAL);

   while(TRUE)
   {
      if((onCNTstartF==0)&&(eventF==0))
      {
         SLEEP();
      }
   }

}

I out-commented almost all the program, the sentence is still there.
Also if I put a break point in the first line of the main the sentence appears.

Can somebody explain me what I am doing wrong?

Best wishes
Joe


Last edited by gjs_rsdi on Thu Aug 31, 2017 6:24 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19551

View user's profile Send private message

PostPosted: Mon Aug 28, 2017 7:23 am     Reply with quote

First thing, a 'short' in CCS, is a one bit integer. Just 0 or 1.....

In CCS:

int, is 8bit
long is 16bit
short is 1bit.

This is because they kept to the original K&R defintions, which say that the default size for an integer, should be the native size for the hardware. So since the PIC is an 8bit processor, int is an int8.
This is also why it is better _not_ to use names (like short and long), but to be explicit on sizes, and use int8, int16 etc..

Then general comment. You should always put a 'nop' (delay_cycles(1)) as the instruction after a sleep. This instruction is 'prefetched' when the chip goes to sleep. If an interrupt occurs between the chip intending to sleep, and going to sleep, or something else affects the PC, this can result in the instruction being mishandled.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

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

PostPosted: Mon Aug 28, 2017 2:12 pm     Reply with quote

Hi Ttelmah

Thanks you for the prompt answer and the advice.
* I put a delay_cycles(1); after the sleep.
* Changed the int definitions as bellow:
Code:
int8 flashledCNT=0;
int8 timer1startCNT=0;
int1 onCNTstartF=0;
int1 eventF=0;
int1 toggleA2timeF=0;
int1 eventA3value=0;
int1 eventA4value=0;

But the problem persists, at the first break point I am getting the same:
Quote:
CORE-W0014: Halted due to PC incrementing over the Maximum PC address and wrapping back to Zero

This sentence affects the program when running?
I am using just 8 bit microcontrollers (18, 28, 40 pins) and I never got this sentence before. Maybe is something connected to the 8 pin microcontrollers?

Best wishes
Joe
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 28, 2017 2:23 pm     Reply with quote

The CORE-W0014 message from the MPLAB vs. 8.92 simulator is caused
by the program calling address 0x3FF to get the OSCCAL value.

I went to View / Program Memory and MPLAB places a RETLW 00
instruction there. So that's OK.

The 12F675 data sheet gives the reason why we get the message:
Quote:

4.7 Program Counter

As a program instruction is executed, the Program
Counter (PC) will contain the address of the next
program instruction
to be executed.

One way to get rid of that message is to go to Debugger / Settings /
Break Options and set "Core (including stack)" warnings to Ignore.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

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

PostPosted: Mon Aug 28, 2017 3:54 pm     Reply with quote

Thank you PCM programmer Smile
It makes the subject clear

Best wishes
Joe
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