Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
00001 /* Includes ------------------------------------------------------------------*/ 00002 #include "mbed.h" 00003 #include "stm32f4xx_hal_tim.h" 00004 00005 /* Private variables ---------------------------------------------------------*/ 00006 TIM_Encoder_InitTypeDef encoder1, encoder2; 00007 TIM_HandleTypeDef timer1, timer2; 00008 00009 /* Private function prototypes -----------------------------------------------*/ 00010 void EncoderInit(TIM_Encoder_InitTypeDef * encoder, TIM_HandleTypeDef * timer, TIM_TypeDef * TIMx, uint32_t maxcount, uint32_t encmode); 00011 00012 00013 Serial pc(USBTX, USBRX); 00014 00015 int main(void) 00016 { 00017 uint16_t count1=0, count2=0; 00018 pc.printf("\e[1;1H\e[2J"); 00019 00020 /* Initialize Timer as Encoder */ 00021 00022 EncoderInit(&encoder1, &timer1, TIM1, 65535, TIM_ENCODERMODE_TI2); 00023 EncoderInit(&encoder2, &timer2, TIM3, 65535, TIM_ENCODERMODE_TI2); 00024 00025 while (1) 00026 { 00027 count1=__HAL_TIM_GET_COUNTER(&timer1); /* Read Counter Value */ 00028 count2=__HAL_TIM_GET_COUNTER(&timer2); /* Read Counter Value */ 00029 printf("COUNT1 %d COUNT2 %d\r\n", count1, count2); 00030 00031 wait(0.1); 00032 } 00033 }
Generated on Tue Jul 12 2022 17:56:30 by
1.7.2