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

unwanted 'break' during debug

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








unwanted 'break' during debug
PostPosted: Wed Mar 04, 2009 5:34 pm     Reply with quote

I am playing with an ICD and when I started designing my INT_EXT interrupt it now breaks when the interrupt routine is supposed to fire off.

In other words, when I have a falling edge on B0 the software halts in the middle of my:
Code:
 for(;;){

//lots o' code

}

This is without any breakpoints enabled in the code. And what's really annoying, my interrupt routine isn't being run. I'm using PCH version 4.082

I'm going through and putting #if 0 around large sections of code just to see if that does anything.

If anyone has seen something like this I would love to know.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 5:56 pm     Reply with quote

Post your PIC. Post your ICD manufacturer and full ICD name.
Guest








PostPosted: Thu Mar 05, 2009 7:30 am     Reply with quote

PIC 18F4680

ICD is a Microchip MPLAB ICD2
Guest








PostPosted: Thu Mar 05, 2009 8:39 am     Reply with quote

I've ripped all my code out and it still happens.

When I get an external interrupt on the B0 pin it breaks at the while(1) even if I don't have any breakpoints enabled.




Code:

#define 18F4680

#include <18F4680.h>
#DEVICE HIGH_INTS=TRUE
#OPT 0


void init_hardware(void);

#include "device.h"

unsigned char test3=0;
unsigned char test2=0;

unsigned char SendIdentDevFlag = FALSE;



void main(void)
{
   delay_ms(500);               //Let the CP power up
   init_hardware();

   while(1){}
}


void init_hardware(void)
{
   *TRISA = 0x20;
   *TRISB = 0xE7;   
   *TRISC = 0x91;
   *TRISD = 0x00;
   *TRISE = 0x08;

   bit_clear(*INTCON2,RBPU);               //Enable the pullup resister for PORTB
   /********************************************************/
   /*   Set up async usart                           */
   /*  19200 WAS 576000 8-N-1                        */
   /*  High Baud Rate (BRGH = 1) 16 if 1, 64 if 0         */
   /*   SPBRG = ((Fosc/Desired Baud Rate)/16) - 1         */
   /*   SPBRG = ((3686400/57600)/16) - 1               */
   /*   SPBRG = 3                                 */
   /********************************************************/
   *SPBRG = 47;
   bit_set(*TXSTA,BRGH);               //High speed
   bit_set(*BAUDCON,BRG16);            //16-bit
   bit_clear(*TXSTA,SYNC);               //Asyncronous
   bit_set(*RCSTA,SPEN);               //Enable Serial Port
   bit_set(*RCSTA,CREN);               //Enable receiver

   /********************************************************/
   /*   SPI Setup                                  */
   /********************************************************/
   setup_spi(SPI_MASTER | SPI_CLK_DIV_64 | SPI_L_TO_H);
   bit_set(*SSPCON1, SSPEN);            //Enable Sync Serial Port
   bit_clear(*SSPSTAT, SMP);            //Input data sampled at end of data output
   bit_clear(*SSPCON1, CKP);            //Clock zero at idle
   bit_clear(*SSPSTAT, CKE);            //Transmit on clock transition from Idle to Active (Low to High)
   
   /********************************************************/
   /*   The max speed of this device is 75kHz.            */
   /*   Fosc/divisor = SPI clock speed                  */
   /*   3686400/64 = 57.6kHz is the actual clock speed      */
   /********************************************************/   
   

   /********************************************************/
   /*   Setup Timer                                 */
   /*   Internal speed = Fosc/4 = 921600               */
   /*                  Interval of 1ms      Error      */
   /*   No prescale:   1.1 usec       922      0.07%      */
   /*   Prescale 2:      2.2 usec      461      0.17%      */
   /*   Prescale 4:      4.3 usec      230      0.17%      */
   /*   Prescale 8:      8.7 usec      115      0.17%      */
   /*   Prescale 16:   17.4 usec      58      1.01%      */
   /*   Prescale 32:   34.7 usec      29      2.86%      */
   /*   Prescale 64:   69.4 usec      14      2.86%      */
   /********************************************************/
   setup_timer_1(T1_INTERNAL| T1_DIV_BY_1);//| RTCC_8_BIT);

   /********************************************************/
   /*   Setup CCP (Capture/Compare)                     */
   /*   Interrupt on compare                        */
   /********************************************************/
   //setup_ccp1(CCP_COMPARE_RESET_TIMER);
   //CCP_1 = 922;
   /********************************************************/
   /*   Set Up Interrupts                           */
   /********************************************************/
   //ext_int_edge(INT_RDA,H_TO_L);
   ext_int_edge(0,H_TO_L);
   ext_int_edge(1,H_TO_L);

   setup_wdt(WDT_OFF);

   enable_interrupts(INT_RDA);
    clear_interrupt(INT_EXT);
   enable_interrupts(INT_EXT);
   //enable_interrupts(INT_EXT1);
   disable_interrupts(INT_EXT1);
   disable_interrupts(INT_RB);
   //enable_interrupts(INT_CCP1);
   //enable_interrupts(INT_TIMER1);  DO NOT USE
   //disable_interrupts(GLOBAL);
   enable_interrupts(GLOBAL);
}

Ttelmah
Guest







PostPosted: Thu Mar 05, 2009 10:21 am     Reply with quote

Er. Of course it will.
You are enabling the interrupts, but have not declared an interrupt handler. There is no code present for the interrupt to go to....

Best Wishes
Guest








PostPosted: Thu Mar 05, 2009 10:27 am     Reply with quote

Cut and Paste Error:


Code:

#int_EXT
void ext_isr()
{
   unsigned char testme = 0;

   SendIdentDevFlag = TRUE;
   testme = 5;
   if(testme == 5)
      testme++;
}

void main(void)
{
   delay_ms(500);               //Let the CP power up
   init_hardware();

   while(1){}
}

void init_hardware(void)
{
   *TRISA = 0x20;
   *TRISB = 0xE7;   
   *TRISC = 0x91;
   *TRISD = 0x00;
   *TRISE = 0x08;

   bit_clear(*INTCON2,RBPU);               //Enable the pullup resister for PORTB
   /********************************************************/
   /*   Set up async usart                           */
   /*  19200 WAS 576000 8-N-1                        */
   /*  High Baud Rate (BRGH = 1) 16 if 1, 64 if 0         */
   /*   SPBRG = ((Fosc/Desired Baud Rate)/16) - 1         */
   /*   SPBRG = ((3686400/57600)/16) - 1               */
   /*   SPBRG = 3                                 */
   /********************************************************/
   *SPBRG = 47;
   bit_set(*TXSTA,BRGH);               //High speed
   bit_set(*BAUDCON,BRG16);            //16-bit
   bit_clear(*TXSTA,SYNC);               //Asyncronous
   bit_set(*RCSTA,SPEN);               //Enable Serial Port
   bit_set(*RCSTA,CREN);               //Enable receiver

   /********************************************************/
   /*   SPI Setup                                  */
   /********************************************************/
   setup_spi(SPI_MASTER | SPI_CLK_DIV_64 | SPI_L_TO_H);
   bit_set(*SSPCON1, SSPEN);            //Enable Sync Serial Port
   bit_clear(*SSPSTAT, SMP);            //Input data sampled at end of data output
   bit_clear(*SSPCON1, CKP);            //Clock zero at idle
   bit_clear(*SSPSTAT, CKE);            //Transmit on clock transition from Idle to Active (Low to High)
   
   /********************************************************/
   /*   The max speed of this device is 75kHz.            */
   /*   Fosc/divisor = SPI clock speed                  */
   /*   3686400/64 = 57.6kHz is the actual clock speed      */
   /********************************************************/   
   

   /********************************************************/
   /*   Setup Timer                                 */
   /*   Internal speed = Fosc/4 = 921600               */
   /*                  Interval of 1ms      Error      */
   /*   No prescale:   1.1 usec       922      0.07%      */
   /*   Prescale 2:      2.2 usec      461      0.17%      */
   /*   Prescale 4:      4.3 usec      230      0.17%      */
   /*   Prescale 8:      8.7 usec      115      0.17%      */
   /*   Prescale 16:   17.4 usec      58      1.01%      */
   /*   Prescale 32:   34.7 usec      29      2.86%      */
   /*   Prescale 64:   69.4 usec      14      2.86%      */
   /********************************************************/
   setup_timer_1(T1_INTERNAL| T1_DIV_BY_1);//| RTCC_8_BIT);

   /********************************************************/
   /*   Setup CCP (Capture/Compare)                     */
   /*   Interrupt on compare                        */
   /********************************************************/
   //setup_ccp1(CCP_COMPARE_RESET_TIMER);
   //CCP_1 = 922;
   /********************************************************/
   /*   Set Up Interrupts                           */
   /********************************************************/
   //ext_int_edge(INT_RDA,H_TO_L);
   ext_int_edge(0,H_TO_L);
   ext_int_edge(1,H_TO_L);

   setup_wdt(WDT_OFF);

   //enable_interrupts(INT_RDA);
    clear_interrupt(INT_EXT);
   enable_interrupts(INT_EXT);
   //enable_interrupts(INT_EXT1);
   disable_interrupts(INT_EXT1);
   disable_interrupts(INT_EXT2);
   disable_interrupts(INT_RB);
   //enable_interrupts(INT_CCP1);
   //enable_interrupts(INT_TIMER1);  DO NOT USE
   //disable_interrupts(GLOBAL);
   //enable_interrupts(GLOBAL);
}
Ttelmah
Guest







PostPosted: Thu Mar 05, 2009 10:32 am     Reply with quote

Get rid of the line HIGH_INTS=TRUE.
You are enabling high priority interrupts, but have not declared any interrupt high priority, so no handler will be present for these. _However_, INT_EXT, is automatically made high priority if these are enabled. So INT_EXT, will vector to the non existent handler, and will never reach it's intended handler.
HIGH_INTS=TRUE, should only ever be set, if you are using high priority interrupts.

Best Wishes
Guest








PostPosted: Thu Mar 05, 2009 10:38 am     Reply with quote

Done, and still happening.
Ttelmah
Guest







PostPosted: Thu Mar 05, 2009 10:57 am     Reply with quote

There are several things in your code that 'worry' me.
First, your accesses using TRISA etc., as pointers. You have not 'typed' these, so it is very likely that the results will not be as expected. Why not use the CCS TRIS functions?.
Then the same applies for setting the register pullups.
Then the same for setting the serial port.
Then the same for the SPI. You half let the compiler do it, then go manual.
If you want to write your code like assembler, then use assembler. If you are going to use a compiler, why not let it do it's work?.
You don't show your fuses, you don't show your clock definition, etc. etc..
At this point, knowing how the registers have really been setup, is hard.
Seriously, you could do a basic program, in less than 30 lines, that does everything you are showing. This should be compilable, so we can see the problem. If this still behaves the same way, then it is almost certainly a ICD problem, but with what you post, it could easily be something unexpected happening...

Best Wishes
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