stm32 UART 통신으로 led 제어하고 Buzzer 여러 소리 내기
#
코드
if(rxflag == 1)
{
rxflag = 0;
uint8_t rxdata = LL_USART_ReceiveData8(USART1);
LL_USART_TransmitData8(USART1, rxdata);
if(rxdata == 'h' || rxdata == 'H')
{
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, GPIO_PIN_SET);
}
else if(rxdata == 'l' || rxdata == 'L')
{
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, GPIO_PIN_RESET);
}
else if(rxdata == '1')
{
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
TIM3->PSC = 35294/261-1;
HAL_Delay(200);
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
}
.....
}
#
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1); @
TIM3->PSC = 35294/261-1;
HAL_Delay(200);
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1); @
@ : 이것을 작성하지 않으면 소리가 끊기지 않는다.
Comments
Post a Comment