해당예제를 조금 더 수정하면
UART1 에서 UART2로 서로 연결할 수 있겠네?
[링크 : https://riptutorial.com/stm32/example/29940/echo-application---hal-library]
UART1은 115200 UART2는 9600인데 크게 문제 없이 잘 되는 듯?
char byte;
char byte3;
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART1)
{
/* Transmit one byte with 100 ms timeout */
HAL_UART_Transmit(&huart3, &byte, 1, 100);
/* Receive one byte in interrupt mode */
HAL_UART_Receive_IT(&huart1, &byte, 1);
}
if (huart->Instance == USART3)
{
/* Transmit one byte with 100 ms timeout */
HAL_UART_Transmit(&huart1, &byte3, 1, 100);
/* Receive one byte in interrupt mode */
HAL_UART_Receive_IT(&huart3, &byte3, 1);
}
}
int main(void)
{
HAL_UART_Receive_IT(&huart1, &byte, 1);
HAL_UART_Receive_IT(&huart3, &byte3, 1);
while (1)
{
}
}
'embeded > Cortex-M3 STM' 카테고리의 다른 글
stm32 RST pull-up reset fail (0) | 2021.08.02 |
---|---|
STM32 RDP(ReaD Protection) (0) | 2021.07.02 |
STM32CubeIDE / HAL register callbacks (0) | 2021.02.03 |
STM32CubeIDE 주의사항(?) (0) | 2021.02.02 |
STM32F103 관련 용어 (0) | 2021.02.02 |