Page 190 - 3-1
P. 190
NVIC_Init(&NVIC_InitStructure);
}
void TIM_Configuration()
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
/* TIM2 Initialize */
TIM_TimeBaseStructure.TIM_Period=1000-1;
TIM_TimeBaseStructure.TIM_Prescaler=36-1;
TIM_TimeBaseStructure.TIM_ClockDivision=0;
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2,&TIM_TimeBaseStructure);
/* TIM2 PWM Setting */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; // 0x60, "110"
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = CCR1_Val;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_High;
TIM_OC1Init(TIM2,&TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Enable);
/* TIM2 Enale */
TIM_ARRPreloadConfig(TIM2, ENABLE);
TIM_Cmd(TIM2,ENABLE);
//TIM_ITConfig(TIM2,TIM_IT_Update, ENABLE); // interrupt enable
// PWM 설정
}
void USART1_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 9600 ;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx |
- 190 -