UART interrupt transmission or reception not happening
I am stuck dont know what i am doing is wrong ... have been stuck for 2-3 days whenever i debug it just stops (not end just that debug arrow disappears and dont move forward) after HAL_UART_Transmit_IT() in int main().
#include <stdint.h>
#include "stm32f4xx_hal.h"
#include <string.h>
#include <stdio.h>
/*
* BOARD INFO :-
*
* USART 1
* USART_TX - PA9 AF7
* USART_RX - PA10 AF7
*
* */
#if !defined(__SOFT_FP__) && defined(__ARM_FP)
#warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
#endif
/* GLOBAL VARIABLES */
//UART HandleTypeDef
UART_HandleTypeDef Uart1;
void UART1_Init(void);
const uint8_t txbuffer[10]={1,2,3,4,5,6,7,8,9,10};
uint8_t rxbuffer[10];
uint32_t tx_count,rx_count;
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
tx_count++;
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
rx_count++;
}
int main(void)
{
HAL_Init();
UART1_Init();
HAL_UART_Transmit_IT(&Uart1,txbuffer,10);
HAL_UART_Receive_IT(&Uart1,rxbuffer,10);
while(1)
{
}
// /* Loop forever */
// for(;;);
}
void SysTick_Handler(void)
{
HAL_IncTick();
}
void UART1_Init(void)
{
// Configure Clock for UART
__HAL_RCC_GPIOA_CLK_ENABLE();
//GPIO init typedef
GPIO_InitTypeDef GpioStruct;
__HAL_RCC_USART1_CLK_ENABLE();
// GPIO Configuration
GpioStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10;
GpioStruct.Mode = GPIO_MODE_AF_PP;
GpioStruct.Alternate = GPIO_AF7_USART1;
GpioStruct.Pull = GPIO_NOPULL;
GpioStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(GPIOA,&GpioStruct);
// USART1 Configuration
Uart1.Instance = USART1; // USART1 Base Address is given
// Don't get confused between UART and USART there is just a bit difference
// We are configuring USART2 as UART
Uart1.Init.BaudRate = 115200;
Uart1.Init.WordLength = UART_WORDLENGTH_8B;
Uart1.Init.StopBits = UART_STOPBITS_1;
Uart1.Init.Mode = UART_MODE_TX_RX;
Uart1.Init.Parity = UART_PARITY_NONE;
Uart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
Uart1.Init.OverSampling = UART_OVERSAMPLING_16;
HAL_UART_Init(&Uart1);
// NVIC FOR priority and enabling IRQ
HAL_NVIC_SetPriority(USART1_IRQn,0,0);
HAL_NVIC_EnableIRQ(USART1_IRQn);
}
void UART1_IRQHandler(void)
{
HAL_UART_IRQHandler(&Uart1);
}
