embeded/Cortex-M3 STM
bluepill stm32f103c8t6 USB CDC 리셋이후 안되는 문제
구차니
2026. 1. 27. 11:35
USB 에서 장치를 다시 인식시키려면, D+ 라인을 풀다운 해주어야 한다고 한다.
그래서 reset 누르고 재기동 하면 ACM이 살아는 있지만 정상적으로 작동을 하지 않는건가?
| If you reset the bluepill you need to pull down the D+ line for several milliseconds to let know the host that it has to start the enumeration process. |
[링크 : https://stackoverflow.com/questions/54939948/stm32-usb-cdc-after-hardware-reset]
USB_DEVICE/App/usb_device.c 에 있는 MX_USB_DEVICE_Init() 을 아래와 같이 추가해준다.
그러면 일정 시간 이후에 다시 붙으면서 /dev/ttyACM0로 데이터가 출력된다.
| void MX_USB_DEVICE_Init(void) { /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ /* Rendering hardware reset harmless (no need to replug USB cable): */ GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOA_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); /*Configure GPIO pin : PA12, a.k.a. USB_DP */ GPIO_InitStruct.Pin = GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_Delay(5); /* Hardware reset rendered harmless! */ /* USER CODE END USB_DEVICE_Init_PreTreatment */ ... } |
[링크 : https://stackoverflow.com/questions/54939948/stm32-usb-cdc-after-hardware-reset]