2021-12-23 04:58 AM
uint8_t tx_data[2] = "AT";
uint8_t rx_data[10];
HAL_Delay(1000);
while (1)
{
HAL_UART_Transmit (&huart1, tx_data, sizeof(rx_data) , 250);
HAL_Delay(500);
HAL_UART_Receive(&huart1,rx_data, 20,1000);
HAL_GPIO_TogglePin (GPIOA, LED_Pin);
HAL_Delay(500);
}
2021-12-23 10:52 AM
add togle led and enable usart irq
2021-12-23 11:21 AM
I did like this , tried with both "AT" and "AT\r\n" same
uint8_t tx_data[4]="AT\r\n";
uint8_t rx_data[10];
/* USER CODE BEGIN 4 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Receive_IT(&huart2, rx_data, 10);
}
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Transmit_IT(&huart2, tx_data, sizeof (tx_data));
}
int main(void)
{
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_UART_Transmit_IT(&huart2, tx_data, 4);
HAL_UART_Receive_IT (&huart2, rx_data, 10);
HAL_GPIO_TogglePin (GPIOA, LD2_Pin);
HAL_Delay (250);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
2021-12-23 11:23 AM
OK, back to really basic debugging:
2021-12-23 11:28 AM
No change to nonblocking IT code i say only enable IRQ nothing more.
Normal call isnt POLL but blocking .
IT and DMA is non blocking offload code.
Blink work?
And use
HAL_UART_Transmit (&huart2, "AT\r\n", 4 , 250);
HAL_UART_Receive(&huart2,rx_data, 10,1500);
2021-12-23 11:28 AM
seems I have configuration issue. it was a good idea to short tx,rx, thanks. Could you instruct me top by step to re configure? I would really appreciate
2021-12-23 11:54 AM
now I tried to test other UART pins(uart1) , I shorted pins, now I receive only the first character of the data . how can I get all the transmitted data at once?
2021-12-23 12:28 PM
I changed the uart port it worked, thank you very much. don't know why on uncle uart2 , PA2,3 didn't work
2021-12-26 05:21 PM
code worked at Nucleo L476, but now I uploaded same code to custom board with STM32-L072KB chip, and shorted UART pins, I am sending "AT" from TX and receiving only 1st letter "A". anyone know why?
uint8_t tx_data[2]="AT";
uint8_t rx_data[10];
int main(void)
.......
while (1)
{
/* USER CODE END WHILE */
HAL_UART_Transmit(&huart1,tx_data, sizeof (tx_data),1500);
HAL_UART_Receive(&huart1,rx_data, 10,1500);
HAL_Delay(1000);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
note: UART baudrate 9600
2021-12-27 01:05 AM
2021-12-27 03:54 AM
I don't understand what you mean .
same code works fine on Nucleo-L476 board, but on L072 mcc I am running same code, having this issue