1. CUBE MX SET
2. GENERATE CODE
3. Sorce Code
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
HAL_StatusTypeDef RcvStat ;
uint8_t bufftx[10] = "Hello!\n" ;
uint8_t UsartData[10] ;
HAL_UART_Transmit(&huart2, bufftx, 10, 100) ; // send start data
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
RcvStat = HAL_UART_Receive(&huart2, UsartData, 1, 100) ; // receive data
if (RcvStat == HAL_OK) { // receive check
HAL_UART_Transmit(&huart2, UsartData, 1, 100) ; // send received data
}
}
/* USER CODE END 3 */
}
코드는 좀더 들여다 봐야 할 것 같다....
Interrupt Enable은 왜 했는지?
Serial 확인시 1번만 수신되고, Loopback 기능인 것 같다.
'Project > Nucleo-F103RB' 카테고리의 다른 글
Nucleo-F103RB Serial 통신3 (0) | 2019.05.27 |
---|---|
Nucleo-F103RB Serial 통신2 (0) | 2019.05.21 |
Nucleo-F103RB 시리얼통신 입력으로 제어 (0) | 2019.05.21 |
Nucleo-F103RB LED 켜기 (0) | 2019.05.21 |
Nucleo-F103RB 개발환경 (0) | 2019.05.21 |