TIM2->CR1&=(uint16_t)(~((uint16_t)TIM_CR1_CEN));// Disable the TIM Counter
TIM2->PSC=(uint16_t)AFSK_BAUDRATE_TIM_PSC-1;
TIM2->ARR=(uint16_t)((SystemCoreClock/(AFSK_BAUDRATE*AFSK_BAUDRATE_TIM_PSC))-1);// timer value calculated according to baud rate 999 for 100bd, autoreload 120
// for baudrate (auto-reload register)
TIM2->CR1|=TIM_CR1_CEN;// enable timer again
TIM2->DIER|=TIM_DIER_UIE;// Enable the interrupt
// TIM21 - Generating tones
TIM21->CR1&=(uint16_t)(~((uint16_t)TIM_CR1_CEN));// Disable the TIM Counter
TIM21->PSC=(uint16_t)AFSK_TONE_TIM_PSC-1;
AFSK_timer_handler();// Handle modulation for setting autoreload for TIM21