cancel
Showing results for 
Search instead for 
Did you mean: 

HardFault_Handler, SIGTRAP trace/breakpoint trap

BNist.1
Associate II

Hello everyone!

I am trying to read sensor data from an FSR402 using a STM32WB55CG in DMA with a temperature sensor as well.

For now I am mostly focusing on the FSR to also make the conversion from voltage to newtons.

After implementing the code for the conversion the programmed stopped working saying this:

Program received signal SIGTRAP, Trace/breakpoint trap.
HardFault_Handler () at ../Core/Src/stm32wbxx_it.c:84
84	{

I really don't know how to deal with all of this. I have already read something about the GDB server which I have never used as this would be my first time doing this type of project. However I notice that for the GDB I would need some connector that I do not have.

I will also attach a photo of my code where I am doing the conversion for the sensor.

/* USER CODE BEGIN 0 */
uint32_t ADC_BUFF[2], val[2], temperature, fsrResistance, fsrConductance, fsrForce;
float vsense = 3.3/4096;
float resistor = 10000;
float voltageIN = 3300;
 
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc){
 
 
	for(int i =0; i<2; i++){
			val[i] = ADC_BUFF[i];
		}
 
		temperature = ((ADC_BUFF[1] * vsense - 0.76)/ 0.0025) + 25;
 
 
		fsrResistance = ((voltageIN - ADC_BUFF[0])*resistor)/ADC_BUFF[0]; // Ohms
		fsrConductance = 1000000/fsrResistance; //microOhms
		if(fsrConductance <= 1000){
			fsrForce = fsrConductance/80;
		} else{
			fsrForce = fsrConductance - 1000;
			fsrForce /= 30;
		}
		HAL_Delay(1000); // DELAY OF 1 SECOND
}
 
/* USER CODE END 0 */

If you guys had any idea how I could solve this, I would be really grateful!0693W000000X7YHQA0.png

6 REPLIES 6
Piranha
Chief II

> GDB server which I have never used

You are already using it - look at the bottom line at your call stack window... ;)

Hard faults can also be debugged: http://www.keil.com/appnotes/files/apnt209.pdf

fsrResistance = ((voltageIN - ADC_BUFF[0])*resistor)/ADC_BUFF[0]; // Ohms
fsrConductance = 1000000/fsrResistance; //microOhms

Both of these lines can get into division by zero, which probably is your problem.

BNist.1
Associate II

Thanks for the answer! I managed to solve the problem after all!

Hi BNist.1, could you please tell me how to solve this problem ?

I guess he simply checks if the divider is zero.

if (fsrResidance) ...

Madhav
Associate

please give the solution of this problem. i urgently need this.

 

Hi @Madhav ,

Original post started on 2020. I'm not sure if you have the same issue/symptoms/conditions...

Could you please start a new thread where you describe with details your current situation?

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.