cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CUBE IDE STM32L152VBTx and WakeupCallback -- None?

Eddiie
Associate II

Hello,

I am moving code from one MCU to this old STM32L152 in where the UART is configured as Multiprocessor Mode.
I am using STM32 CubeIDE

I get compile error..   It looks to me like there is no WakeupCallback at all.

 

HAL_UARTEx_WakeupCallback
HAL_UART_WakeupCallback

 

How was this done?  Where is it?  :)

 

4 REPLIES 4
Sarra.S
ST Employee

Hello @Eddiie

Please refer to RM0038, USART section, the STM32L152 does not support waking up from stop mode via UART directly, a workaround is to configure an EXTI line for the USART Rx pin, which will allow you to wake up the MCU from low power mode.

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.

Eddiie
Associate II

Hello @Sarra.S 

Thank you for your reply.

I am looking for callback function when there is an address match when UART is in MultiProcessor mode.

This is has nothing to do with power, really.  Unless I am misunderstanding the Mute/Wakeup (events?)

 

From what I understand, when the UART is in Multiprocessor mode and Address match is selected, the UART looks for the 9th bit, then compares the 8bit value of the byte to see if it is the address stored in its register.  If so, there is an interrupt triggered,  HAL_UART_WakeupCallback(&huartX)  

 

An example of MultiProcessor mode   Transmit / Receive IT code similar to the UART Transmit / Receive IT 2 Board examples would be helpful.

 

So is the HAL_UART_WakeupCallback for Power related things and not UART Multiprocessor related?

 

 

Eddiie
Associate II

I have hacked something together that seems to work, but the rxBuffer keeps incrementing, it never resets to 0, filling up the array.

?

Transmitter code

 

 

/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define MAXBUFFERLENGTH  256
/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart2;
__IO ITStatus UartReady = RESET;

/* USER CODE BEGIN PV */
uint16_t	rxBuffer[MAXBUFFERLENGTH] = {0};
uint16_t	txBuffer[MAXBUFFERLENGTH] = {0};

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART2_UART_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */
  // Command 1
  txBuffer[0] = 0x10E ;  txBuffer[1] = 0x071 ;  txBuffer[2] = 0x006 ;
  txBuffer[3] = 0x001 ;  txBuffer[4] = 0x01F ;  txBuffer[5] = 0x031 ;
  txBuffer[6] = 0x000 ;

  // Command 2
  //txBuffer = { 0x10E, 0x0B0, 0x008, 0x000, 0x008, 0x000, 0x03E, 0x4C };

  // Command 3
  //txBuffer = {0x10E, 0x0F1, 0x008, 0x001, 0x000, 0x010, 0x0C5, 0x002 };

  // Command 4
  //txBuffer = {0x10E, 0x071, 0x006, 0x001, 0x01F, 0x031 };

  // Command 5
  //txBuffer = {0x10E, 0x0B0, 0x008, 0x000, 0x009, 0x000, 0x0E6, 0x055 };

  // Command 6  (same command 3)
  //txBuffer = {0x10E, 0x0F1, 0x008, 0x001, 0x000, 0x010, 0x0C5, 0x002 };


  // Command poll
  //txBuffer = {0x10E, 0x000 };
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
	  txBuffer[0] = 0x10E ;  txBuffer[1] = 0x071 ;  txBuffer[2] = 0x006 ;
	  txBuffer[3] = 0x001 ;  txBuffer[4] = 0x01F ;  txBuffer[5] = 0x031 ;
	  txBuffer[6] = 0x000 ;

	  if(HAL_UART_Transmit(&huart1, (uint8_t*)txBuffer, 7, 1000)!= HAL_OK)
	  {
	    Error_Handler();
	  }

	  /*##-5- Wait for the end of the transfer ###################################*/
//	  while (&huart1 != SET)
//	  {
//	  }

	  /* Reset transmission flag */
//	  huart1 = RESET;
	  HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
	  HAL_Delay(500);

	  txBuffer[0] = 0x101 ;  txBuffer[1] = 0x088 ;  txBuffer[2] = 0x088 ;
	  txBuffer[3] = 0x088 ;  txBuffer[4] = 0x088 ;  txBuffer[5] = 0x088 ;
	  txBuffer[6] = 0x000 ;

	  if(HAL_UART_Transmit(&huart1, (uint8_t*)txBuffer, 7, 1000)!= HAL_OK)
	  {
	    Error_Handler();
	  }
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief USART1 Initialization Function
  * @PAram None
  * @retval None
  */
static void MX_USART1_UART_Init(void)
{

  /* USER CODE BEGIN USART1_Init 0 */

  /* USER CODE END USART1_Init 0 */

  /* USER CODE BEGIN USART1_Init 1 */

  /* USER CODE END USART1_Init 1 */
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 19200;
  huart1.Init.WordLength = UART_WORDLENGTH_9B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART1_Init 2 */

  /* USER CODE END USART1_Init 2 */

}

/**
  * @brief USART2 Initialization Function
  * @PAram None
  * @retval None
  */
static void MX_USART2_UART_Init(void)
{

  /* USER CODE BEGIN USART2_Init 0 */

  /* USER CODE END USART2_Init 0 */

  /* USER CODE BEGIN USART2_Init 1 */

  /* USER CODE END USART2_Init 1 */
  huart2.Instance = USART2;
  huart2.Init.BaudRate = 115200;
  huart2.Init.WordLength = UART_WORDLENGTH_8B;
  huart2.Init.StopBits = UART_STOPBITS_1;
  huart2.Init.Parity = UART_PARITY_NONE;
  huart2.Init.Mode = UART_MODE_TX_RX;
  huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart2) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART2_Init 2 */

  /* USER CODE END USART2_Init 2 */

}

/**
  * @brief GPIO Initialization Function
  * @PAram None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOC_CLK_ENABLE();
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin : B1_Pin */
  GPIO_InitStruct.Pin = B1_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pin : LD2_Pin */
  GPIO_InitStruct.Pin = LD2_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);

  /* EXTI interrupt init*/
  HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);

/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @PAram  file: pointer to the source file name
  * @PAram  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

 

 

 

 

Receiver code

 

/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define MAXBUFFLENGTH   256
/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
__IO ITStatus UartReady = RESET;
/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart2;

/* USER CODE BEGIN PV */
uint16_t		rxBuffer[MAXBUFFLENGTH] = {0};
uint16_t		txBuffer[MAXBUFFLENGTH] = {0};
/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
void ProcessReceivedData(uint8_t *data, uint16_t size, uint8_t address);
static uint16_t Buffercmp(uint16_t* pBuffer1, uint16_t* pBuffer2, uint16_t BufferLength);
/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART2_UART_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */
  // Start UART reception
//  HAL_UART_Receive_IT(&huart1, (uint8_t*)&rxBuffer, MAXBUFFLENGTH);
  if(HAL_UART_Receive_IT(&huart1, (uint8_t*)rxBuffer, MAXBUFFLENGTH) != HAL_OK){
      Error_Handler();
  }



  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
	  // Your application code here

    /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief USART1 Initialization Function
  * @PAram None
  * @retval None
  */
static void MX_USART1_UART_Init(void)
{

  /* USER CODE BEGIN USART1_Init 0 */

  /* USER CODE END USART1_Init 0 */

  /* USER CODE BEGIN USART1_Init 1 */

  /* USER CODE END USART1_Init 1 */
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 19200;
  huart1.Init.WordLength = UART_WORDLENGTH_9B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_MultiProcessor_Init(&huart1, 0x0E, UART_WAKEUPMETHOD_ADDRESSMARK) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART1_Init 2 */

  /* USER CODE END USART1_Init 2 */

}

/**
  * @brief USART2 Initialization Function
  * @PAram None
  * @retval None
  */
static void MX_USART2_UART_Init(void)
{

  /* USER CODE BEGIN USART2_Init 0 */

  /* USER CODE END USART2_Init 0 */

  /* USER CODE BEGIN USART2_Init 1 */

  /* USER CODE END USART2_Init 1 */
  huart2.Instance = USART2;
  huart2.Init.BaudRate = 115200;
  huart2.Init.WordLength = UART_WORDLENGTH_8B;
  huart2.Init.StopBits = UART_STOPBITS_1;
  huart2.Init.Parity = UART_PARITY_NONE;
  huart2.Init.Mode = UART_MODE_TX_RX;
  huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart2) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART2_Init 2 */

  /* USER CODE END USART2_Init 2 */

}

/**
  * @brief GPIO Initialization Function
  * @PAram None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOC_CLK_ENABLE();
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin : B1_Pin */
  GPIO_InitStruct.Pin = B1_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pin : LD2_Pin */
  GPIO_InitStruct.Pin = LD2_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);

  /* EXTI interrupt init*/
  HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);

/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}

/* USER CODE BEGIN 4 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
  // This function is called when UART reception is complete

  // Extract the address from the received data (MSB of the 9-bit frame)
  uint8_t address = (rxBuffer[0] >> 8 & 0xFF);

  // Calculate the number of received bytes
  uint16_t size = 1; // In 9-bit mode, each frame is 2 bytes, but the address is already accounted for

//  while (UartReady != SET)
//    {
//    }
//  UartReady = RESET;
//  if(HAL_UART_Receive_IT(&huart1, (uint8_t*)rxBuffer, MAXBUFFLENGTH) != HAL_OK){
//      Error_Handler();
//  }

  HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);

  // Process the received data (excluding the address byte)
  ProcessReceivedData((uint8_t*)&rxBuffer, size, address);

  // Restart UART reception
  HAL_UART_Receive_IT(huart, (uint8_t*)&rxBuffer, sizeof(rxBuffer));
}



void ProcessReceivedData(uint8_t *data, uint16_t size, uint8_t address)
{
  // Process the received data based on the size and address
	HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
  // This function will be called each time a packet is received
  // Add your processing logic here


}



/**
  * @brief  Compares two buffers.
  * @PAram  pBuffer1, pBuffer2: buffers to be compared.
  * @PAram  BufferLength: buffer's length
  * @retval 0  : pBuffer1 identical to pBuffer2
  *         >0 : pBuffer1 differs from pBuffer2
  */
static uint16_t Buffercmp(uint16_t* pBuffer1, uint16_t* pBuffer2, uint16_t BufferLength)
{
  while (BufferLength--)
  {
    if ((*pBuffer1) != *pBuffer2)
    {
      return BufferLength;
    }
    pBuffer1++;
    pBuffer2++;
  }

  return 0;
}


/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @PAram  file: pointer to the source file name
  * @PAram  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

 

 

I thought "UartReady" was a flag that was updated by background process.   

This is hacked up code from the Nucleo UART IT sample, with 2 boards.  

 

Eddiie
Associate II

 

The output on the "Receiver" side is -

rxBufferuint16_t [256]0x200000b8
[0...99] uint16_t [100] 0x200000b8
rxBuffer[0] uint16_t 0x10e
rxBuffer[1] uint16_t 0x71
rxBuffer[2] uint16_t 0x6
rxBuffer[3] uint16_t 0x1
rxBuffer[4] uint16_t 0x1f
rxBuffer[5] uint16_t 0x31
rxBuffer[6] uint16_t 0x0
rxBuffer[7] uint16_t 0x10e
rxBuffer[8] uint16_t 0x71
rxBuffer[9] uint16_t 0x6
rxBuffer[10] uint16_t 0x1
rxBuffer[11] uint16_t 0x1f
rxBuffer[12] uint16_t 0x31
rxBuffer[13] uint16_t 0x0
rxBuffer[14] uint16_t 0x10e
rxBuffer[15] uint16_t 0x71
rxBuffer[16] uint16_t 0x6
rxBuffer[17] uint16_t 0x1
rxBuffer[18] uint16_t 0x1f
rxBuffer[19] uint16_t 0x31
rxBuffer[20] uint16_t 0x0
rxBuffer[21] uint16_t 0x10e
rxBuffer[22] uint16_t 0x71
rxBuffer[23] uint16_t 0x6
rxBuffer[24] uint16_t 0x1
rxBuffer[25] uint16_t 0x1f
rxBuffer[26] uint16_t 0x31
rxBuffer[27] uint16_t 0x0
rxBuffer[28] uint16_t 0x10e
rxBuffer[29] uint16_t 0x71
rxBuffer[30] uint16_t 0x6
rxBuffer[31] uint16_t 0x1
rxBuffer[32] uint16_t 0x1f
rxBuffer[33] uint16_t 0x31
rxBuffer[34] uint16_t 0x0
rxBuffer[35] uint16_t 0x10e
rxBuffer[36] uint16_t 0x71
rxBuffer[37] uint16_t 0x6
rxBuffer[38] uint16_t 0x1
rxBuffer[39] uint16_t 0x1f
rxBuffer[40] uint16_t 0x31
rxBuffer[41] uint16_t 0x0
rxBuffer[42] uint16_t 0x10e
rxBuffer[43] uint16_t 0x71
rxBuffer[44] uint16_t 0x6
rxBuffer[45] uint16_t 0x1
rxBuffer[46] uint16_t 0x1f
rxBuffer[47] uint16_t 0x31
rxBuffer[48] uint16_t 0x0
rxBuffer[49] uint16_t 0x10e
rxBuffer[50] uint16_t 0x71
rxBuffer[51] uint16_t 0x6
rxBuffer[52] uint16_t 0x1
rxBuffer[53] uint16_t 0x1f
rxBuffer[54] uint16_t 0x31
rxBuffer[55] uint16_t 0x0
rxBuffer[56] uint16_t 0x10e
rxBuffer[57] uint16_t 0x71
rxBuffer[58] uint16_t 0x6
rxBuffer[59] uint16_t 0x1
rxBuffer[60] uint16_t 0x1f
rxBuffer[61] uint16_t 0x31
rxBuffer[62] uint16_t 0x0
rxBuffer[63] uint16_t 0x0
rxBuffer[64] uint16_t 0x0
rxBuffer[65] uint16_t 0x0
rxBuffer[66] uint16_t 0x0
rxBuffer[67] uint16_t 0x0
rxBuffer[68] uint16_t 0x0
rxBuffer[69] uint16_t 0x0
rxBuffer[70] uint16_t 0x0
rxBuffer[71] uint16_t 0x0
rxBuffer[72] uint16_t 0x0
rxBuffer[73] uint16_t 0x0
rxBuffer[74] uint16_t 0x0
rxBuffer[75] uint16_t 0x0
rxBuffer[76] uint16_t 0x0
rxBuffer[77] uint16_t 0x0
rxBuffer[78] uint16_t 0x0
rxBuffer[79] uint16_t 0x0
rxBuffer[80] uint16_t 0x0
rxBuffer[81] uint16_t 0x0
rxBuffer[82] uint16_t 0x0
rxBuffer[83] uint16_t 0x0
rxBuffer[84] uint16_t 0x0

.....

rxBuffer[255] uint16_t 0x0

 

If it runs long enough, the whole array will fill up.

 

I need to set/reset a flag?