cancel
Showing results for 
Search instead for 
Did you mean: 

UART interrupt not hitting without connecting debugger.

Shivam Prajapati
Associate

I have a Stm32f030k6 custom board and I'm using Keil uV5 IDE. The MCU is interfaced with wifi module over UART. But stm32 wasn't responding to the events sent by wifi module. After lot of testing I found that the UART interrupt is not occuring when standalone. But when I connected ST-link V2 connector to it just works fine. Even when the debugger is not powered through PC it works fine. But when I turn it on without debugger connection it just stucks.

Have a look at the UART Callback function below:

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	HAL_UART_Transmit(&huart1,(uint8_t*)"interrupt\n",sizeof("interrupt\n"),HAL_MAX_DELAY);
		/* Set transmission flag: trasfer complete*/
  UartReady = SET;
	HAL_UART_Receive_IT(&huart1,&a,1);
	temp=a;
	if((!start_flag)&&(temp=='@'))//Start condition
	{
			start_flag =1;
			rxBufIdx=0;
			memset(rxBuf,0,sizeof(rxBuf));
		memset(result,0,sizeof(result));
	}
	else if((temp=='&')&&(rxBufIdx!=0))// end condition
	{
		comand_received_flag=1;
		start_flag=0;
		rxBuf[rxBufIdx++]='\0';	
		
		//connected=1;
		sprintf((char*)result, (char*)rxBuf,10);
		HAL_UART_Transmit(&huart1,(uint8_t*)"Received\n",sizeof("Received\n"),HAL_MAX_DELAY);}
		if(strcmp((const char*)result,"Connected")==0){
		connected=1; HAL_UART_Transmit(&huart1,(uint8_t*)"Connected=1\n",sizeof("Connected=1\n"),HAL_MAX_DELAY);}
		else if(result[0]=='A' ||result[0]=='B'){
			Accident=1;HAL_UART_Transmit(&huart1,(uint8_t*)"Accident=1\n",sizeof("Accident=1\n"),HAL_MAX_DELAY);}
		else if(result[0]=='N'){
			Accident=0;HAL_UART_Transmit(&huart1,(uint8_t*)"Accident=0\n",sizeof("Accident=0\n"),HAL_MAX_DELAY);}
		
	
	else if(start_flag)//push data into Buff
	{
		rxBuf[rxBufIdx++]=temp;
	}
	
}

3 REPLIES 3

Make sure BOOT0 is pulled Low.

Use GPIO to flag interrupt entry/exit.

Stop putting blocking functions in interrupt handlers and callbacks.​

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
RMcCa
Senior II

Could be a grounding issue between the wifi module and the processor that is somehow fixed by plugging in the debugger. Also agree with the comment above. Strip down the isr. I personally wouldn't try transmitting within the rx isr, that's what flags/semaphores are for.​

ZMohd.7
Associate III

Hi Shivam and Clive,

I am facing same issue with STM32F303CBT MCU while program is running in debugging mode using STlink V2, Program working as Intended. each time UART3 Receive interrupt callback function working fine.

And when debugger is off and program running in Normal mode, UART3 received call back function is not calling or not executing.

MCU BOOT0 pin is connected to GND. If you have any solution, please let me know.

Thanks in Advance.

Best Regards

MZ