2018-09-04 01:50 PM
int main(void)
{
/* USER CODE BEGIN 1 */
uint16_t Prescaler=1;
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_TIM1_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
htim1.Instance->PSC = Prescaler;
Prescaler+=1;
if(Prescaler>80) Prescaler=1;
HAL_Delay(500);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
I am trying to generate a pulse train Using the timer .
I am stuck in the task of changing the Frequency within the code in Keil micro vision 5
Need help
Thanks in advance
2018-09-04 01:58 PM
Show your code and others will be more than happy to help you.
2018-09-04 03:58 PM
The frequency is controlled by the ARR and PSC registers.
2018-09-04 05:36 PM
are you using PWM ?
where is the code ?
PWM can be adjusted "on the fly"