Question
Why i cant read and send data between UART2 of a STM32L412RBT6 (PA2 and PA3) and the BlueNRG-M2SP UART(DIO8 and DIO11)
I designed a PCB with an STM32L412RBT6 and a BlueNRG-M2SP, and I checked the connection and I can't read data from the bluetooth module and I can't send data from the STM32.
I made the following code:
stm32l4xx_it.c
void USART2_IRQHandler(void)
{
/* USER CODE BEGIN USART2_IRQn 0 */
/* USER CODE END USART2_IRQn 0 */
HAL_UART_IRQHandler(&huart2);
/* USER CODE BEGIN USART2_IRQn 1 */
HAL_UART_Receive_IT(&huart2, &BLE_Byte, 1);
/* USER CODE END USART2_IRQn 1 */
}main.c
/*BLE private variable*/
char BLE_recv[BLE_RXBuff_SIZE];
char MainBuff_BLE[BLE_MainBuff_SIZE];
uint8_t BLE_Byte;
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
if(huart->Instance == USART2){
BLE_recv[j++] = BLE_Byte;
}
}
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;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART2_Init 2 */
/* USER CODE END USART2_Init 2 */
}Here is a diagram of the connection between the component
I don't understand why it doesn't work
