cancel
Showing results for 
Search instead for 
Did you mean: 

Hard fault that happens only with debug, and using pause/start buttons

Tobe
Senior III

Hi,

i have an issue, where i implemented using DMA. The DMA works seemingly without issues, but when debugging and using the start/pause buttons, the hard fault happens.

Would the be a smart way to *simulate* a pause/start of a debug session??


EDIT:

I found out, that this issue only happens when the interrupt is activated:

 

volatile uint16_t adcArray[12]
void DMA1_Channel2_IRQHandler(){
	ADC_TEST_2_ON

	// Transfer complete
	if( READ_BIT(DMA1->IFCR, DMA_IFCR_CTCIF2) ){
		DMA1->IFCR |= (DMA_IFCR_CTCIF2);		// Clear bit transfer complete

//		tempFETBits 	= 0;
//		battVoltBits 	= 0;
//		throttleBits 	= 0;
//		buttonSensBits 	= 0;

		tempFETBits = adcArray[0];

		ADC_TEST_2_OFF;
	}

	// Transfer error
	if( READ_BIT(DMA1->IFCR, DMA_IFCR_CTEIF2) ){
		DMA1->IFCR |= (DMA_IFCR_CTEIF2);		// Clear bit
		//TODO: save event
		while(1);
	}

	ADC_TEST_2_OFF;
}

 

2 REPLIES 2

Debug the hardfault. Check content of the fault registers (SCB_CFSR and its components). If you are using an IDE which provides you a backtrace (call stack, whateverisitcalled), look at the point where the fault handler was called (taking into mind that imprecise error happens a couple of instructions before that point), in mixed C-disasm view, to see what was the cause of fault.

JW

 

In the meanwhile, i found out, that the hardfault only happens, when i resume out of the DMA handler. But if it was resumed from the DMA handler, while other handlers happend when the DMA handler was active, then this problem does dont happen.

I dont see a problem with my program, so i would just try to work without DMA interrupt. The hard fault was a INVPC.

I wonder if it would haunt me at a later stage?