Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] debugger haults unexpectedly

Status
Not open for further replies.

akshaybhavsar

Full Member level 2
Joined
May 5, 2016
Messages
135
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Activity points
898
Hello,
Plz help meI am using MPlab v3.26 in my project.debugger haults while running.what could b the reason
 

Could be any number of reasons - you will need to tell us a lot more such as the chip, which programmer/debugger you are using, the config settings and what so you actually mean by "debugger haults (sic) while running.".
Can you single step at all? Is there an error message, and if so what is it? When you use the pause button, does ut show part of your source code or a disassembly listing?
Have you got any program to work with the hardware you are using?
Susan
 

I am using pic32mx230f064d.I am using INT1 pin for rising and falling level interrupt.when interrupt comes I am sending packet to server upto 30 character long.I am using timer1,timer3.debugger stops while running

- - - Updated - - -

there might b problem with interrupt priority??
 

Without code or the answers to the questions I asked before, it is really hard to know what is going on. (By 'code' I really mean a small but complete program that exhibits the problem - strip out all of the extraneous code but leave in the code that causes the problem.)
However, if you are writing the ISRs correctly (which basically means that you are not doing long operations in them), my experience is that you almost never need to play with interrupt priorities except in very specific situations.
Susan
 

i came to know the answer..it haults because of timer1.i think i need to change priority of timer1 interrupt...what priority should i set...high or low???
 

You are still not answering my questions.
Please show us the code for the Timer 1 ISR as well as the declarations for all global variables it references.
It would also be useful to see the other ISR code.
I would take a punt that this probably has nothing to do with priorities and everything to do with improperly written code.
Susan
 

Code:
volatile uint_8 TransferRateComplete=0;
extern usint_16 PeriodValue,TransferRateCount;

void __ISR(4,ipl7)TIMER1_handlar(void)
{
	if(IFS0bits.T1IF)
	{
		IFS0bits.T1IF = 0;      //clear flag.
		PR1 = 19531;		//1 sec value.
		TransferRateCount++;
		
		if(TransferRateCount ==( PeriodValue))
		{			
			TransferRateCount = 0;
			TransferRateComplete = 1;
//			T1CONbits.ON = 0;			//disable timer1
//			PR1 = 0;				//1 sec value.
//			TMR1 = 0;
			
//			SendPacket(PacketData ,PacketDataIndx);
			//MinuteFlag = 1;
//			PR1 = 0x9C40;				//1 sec value.
//			T1CONbits.ON = 1;			//enable timer1			
		}
	}		
	
}

- - - Updated - - -

I am sending packet to server.timer 1 is used for time difference between two packets

- - - Updated - - -

Code:
void __ISR(7,ipl7)WATER_LEVEL_INT1_HANDLER(void)
{
    if(IFS0bits.INT1IF)
	{
        if(level=='1')
        {
            level='0';
            
        }
        else
        {
            level='1';
        }
        
         INTCONbits.INT1EP=~INTCONbits.INT1EP;
       // WriteString("SWITCH INTERUPT\n");
         ADC_read();
      
        // WriteString("ADC READ\n");
        calculations();
       //  WriteString("calculations\n");

        set_packet();
        
        // WriteString("packet set \n");
        send_packet();
        
        OpenUart2();
        
       
//		IEC0SET = 0x00000010;			//Enable Timer1 interrupt  
//		T1CONSET = 0x00008000;			//Enable Timer1. 
		IFS0CLR= 0x00000100;	
	}
    
    
    
}

- - - Updated - - -

I am using switch also.whenever i press the switch.it generates interrupt and 1 packet will b sent to server as soon as i press the switch

- - - Updated - - -

I am using timer 1 for 15 sec delay.It means after each 15 sec packet will be sent to server.it work fine if i dont use switch interrupt.it means after each 15 sec packet is sent to server succesfully.but if i add that switxch interrupt routine debugge stops after few minutes

- - - Updated - - -

I am using timer 1 for 15 sec delay.It means after each 15 sec packet will be sent to server.it work fine if i dont use switch interrupt.it means after each 15 sec packet is sent to server succesfully.but if i add that switxch interrupt routine debugge stops after few minutes

- - - Updated - - -

in interrupt routine i am sending packet .for that i need to send command to GSM module in ISR itself (AT+CIPSEND).after sending this command it needs delay.Is it allowed to have delay in ISR?If i remove delay all things work fine.:sad:
 

Delays and ISRs are a generally disastrous combination and should be avoided at all costs. This is the whole reason why state machines are very commonly used so that all delays (between once state and the next for example) all occur at the main code level.
Also, in the ISRs you do not need to check for the IF flag being set. The ISR will not be called unless it is set.
Further, in the ISR you know that the IE flag will be set as well - again the ISR would not be called if it were not. Therefore, while it is not generally a good idea to play with the IE bit inside the ISR itself, if you need to then you can simply turn it off; there is no advantage is toggling it as it must be on to start with.
Not sure why you are resetting the PR1 register in the ISR - it should stay the same when the timer starts counting the next period.
The way I would write this is to have a state machine with an idle state and a "read and send packet" state (or whatever). The machine would be initialised to the 'idle' state and the 15 second timer ISR and the push button ISR would simply move it to the "read and send packet" state which would go back to the idle state when it had done its job. The main loop would then do all the heavy lifting and the ISRs are all very quick and simple.
Susan
 

I removed delay.it seems working fine.thank you for your help.
and RTC is not giving correct value.its running ahead Universal time.
if i reset RTC,after 2 days it seems running few seconds ahead.after 15 days it is running almost 5 minutes ahead.

- - - Updated - - -

when timer overflows,PR1 becomes zero.it needs to be set to its original value again???
 

If PR1 is being reset to zero then either you are doing that in your code (so you can stop that) or you have a hardware problem.
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top