add microsecond timer support
parent
c86a19c1dc
commit
e1dd404c9b
|
@ -104,6 +104,7 @@ void periph_init() {
|
|||
RCC->APB1ENR |= RCC_APB1ENR_CAN3EN;
|
||||
#endif
|
||||
RCC->APB1ENR |= RCC_APB1ENR_DACEN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
|
||||
//RCC->APB1ENR |= RCC_APB1ENR_TIM4EN;
|
||||
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
|
||||
|
|
|
@ -510,6 +510,14 @@ int main() {
|
|||
USART3->CR2 |= USART_CR2_LINEN;
|
||||
#endif
|
||||
|
||||
// init microsecond system timer
|
||||
// increments 1000000 times per second
|
||||
// generate an update to set the prescaler
|
||||
TIM2->PSC = 48-1;
|
||||
TIM2->CR1 = TIM_CR1_CEN;
|
||||
TIM2->EGR = TIM_EGR_UG;
|
||||
// use TIM2->CNT to read
|
||||
|
||||
// enable USB
|
||||
usb_init();
|
||||
|
||||
|
|
Loading…
Reference in New Issue