This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

On STM32h753 UART interrupt is working fine after programming the controller using keil but malfunctions after complete power reset ?

I am working on STM32H753 microcontroller. I want to receive string using UART interrupt and send the same string back on UART. The IDE is keil uvision 5. The problem I am facing is that when I first program the MCU  UART is working fine and I am receiving back the string but after completely switching off the supply and restarting it UART is not working properly and I am not receiving the data I sent. I generated my code using stm32cube

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int main(void)
{
device_init();
HAL_Delay(100);
HAL_UART_Receive_IT(&huart1,recbuf,80);
/* USER CODE BEGIN WHILE */
while (1)
{
if(rec_data == 1)
{
rec_data = 0;
//Clean and Invalidate data cache
//SCB_CleanInvalidateDCache();
HAL_UART_Transmit_IT(&huart1,recbuf,80);
}
}
/* USER CODE END 3 */
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int main(void)
{
device_init();
HAL_Delay(100);
HAL_UART_Receive_IT(&huart1,recbuf,80);
/* USER CODE BEGIN WHILE */
while (1)
{
if(rec_data == 1)
{
rec_data = 0;
//Clean and Invalidate data cache
//SCB_CleanInvalidateDCache();
HAL_UART_Transmit_IT(&huart1,recbuf,80);
}
}
/* USER CODE END 3 */
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
.
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "usart.h"
#include "gpio.h"
#include "config.h"
#include <string.h>
#include "timer.h"
uint8_t recbuf[100],trnsbuf[100];
unsigned char rec_data;
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
UART_HandleTypeDef huart1;
/* USART1 init function */
void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 19200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* @brief Receive an amount of data in interrupt mode.
* @note Function is called under interruption only, once
* interruptions have been enabled by HAL_UART_Receive_IT()
* @param huart: UART handle.
* @retval HAL status
*/
static HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart)
{
uint16_t* tmp;
uint16_t uhMask = huart->Mask;
uint16_t uhdata;
/* Check that a Rx process is ongoing */
if(huart->RxState == HAL_UART_STATE_BUSY_RX)
{
//SCB_DisableICache(); // Disable Instruction-cache at beginning of function in case of success! AKASH EDIT
uhdata = (uint16_t) READ_REG(huart->Instance->RDR);
if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* @brief Send an amount of data in interrupt mode.
* @note Function is called under interruption only, once
* interruptions have been enabled by HAL_UART_Transmit_IT().
* @param huart: UART handle.
* @retval HAL status
*/
static HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart)
{
uint16_t* tmp;
uint16_t uhdata;
/* Check that a Tx process is ongoing */
if (huart->gState == HAL_UART_STATE_BUSY_TX)
{
if(huart->TxXferCount == 0U)
{
/* Disable the TX FIFO threshold interrupt (if FIFO mode is enabled) or
Transmit Data Register Empty interrupt (if FIFO mode is Disabled).
*/
if (READ_BIT(huart->Instance->CR1, USART_CR1_FIFOEN) != RESET)
{
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

0