Could use some help getting a UART working in interrupt mode on a Nucleo H7A3ZI-Q
I've had some success getting UARTs to work on a Nucleo 413ZH board but am struggling to get the same code working on a Nucleo H7A3ZI-Q board. I have a logic analyzer connected to the TX and RX pins on the Nucleo boards. The HAL_UART_Transmit line (line 72) works fine and I can see the whole txBuffer on the logic analyzer. But the HAL_UART_Transmit_IT line (line 73) only transmits the first 2 characters of the txBuffer according to what I see on my logic analyzer.
I'm sure I don't have something in one of the interrupt routines configured correctly but I sure can't figure it out and would appreciate any help.
Thanks
#include <stm32h7xx_hal.h>
#include <stm32_hal_legacy.h>
#ifdef __cplusplus
extern "C"
#endif
void SysTick_Handler(void)
{
HAL_IncTick();
HAL_SYSTICK_IRQHandler();
}
static UART_HandleTypeDef s_UARTHandle = UART_HandleTypeDef();
extern "C" void USART2_IRQHandler()
{
HAL_UART_IRQHandler(&s_UARTHandle);
}
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_Delay(1);
}
static uint8_t rxBuffer[10];
static uint8_t msgBuffer[256];
static uint8_t msgIndex = 0;
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_Delay(1);
}
int main(void)
{
HAL_Init();
__USART2_CLK_ENABLE();
__GPIOD_CLK_ENABLE();
GPIO_InitTypeDef uartGPIO_InitStructure;
//TX
uartGPIO_InitStructure.Pin = GPIO_PIN_5;
uartGPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
uartGPIO_InitStructure.Alternate = GPIO_AF7_USART2;
uartGPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
uartGPIO_InitStructure.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOD, &uartGPIO_InitStructure);
//RX
uartGPIO_InitStructure.Pin = GPIO_PIN_6;
uartGPIO_InitStructure.Mode = GPIO_MODE_AF_OD;
HAL_GPIO_Init(GPIOD, &uartGPIO_InitStructure);
s_UARTHandle.Instance = USART2;
s_UARTHandle.Init.BaudRate = 9600;
s_UARTHandle.Init.WordLength = UART_WORDLENGTH_8B;
s_UARTHandle.Init.StopBits = UART_STOPBITS_1;
s_UARTHandle.Init.Parity = UART_PARITY_NONE;
s_UARTHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
s_UARTHandle.Init.Mode = UART_MODE_TX_RX;
if (HAL_UART_Init(&s_UARTHandle) != HAL_OK)
asm("bkpt 255");
NVIC_EnableIRQ(USART2_IRQn);
uint8_t txBuffer[] = "this is a test of the vgdb UART example";
HAL_UART_Transmit(&s_UARTHandle, (uint8_t*)txBuffer, sizeof(txBuffer), HAL_MAX_DELAY);
HAL_UART_Transmit_IT(&s_UARTHandle, (uint8_t*)txBuffer, sizeof(txBuffer));
HAL_Delay(1000);
}