问题遇到的现象和发生背景
小组比赛要用到舵机,我负责控制舵机的旋转和舵机速度,但是已经一周了,占空比还是不知道咋调,听学长说要修改时钟,但是我改了没反应,之前在Object.c里改了一下,将2500改成了5000,改后变成了旋转180°,将数据改回还是转180°(之前是转大概100°)
问题相关代码,请勿粘贴截图
case CMD_ALL_ID: //0x3006
memcpy(&ctrl_cmd, rxbuf, sizeof(mtlink_all_CMD_t));
ctrl_cmd.UpDown = (-1) * ctrl_cmd.UpDown;
LED_SetPwm(CONSTRAIN(ctrl_cmd.light * 20, 5000, 0));
ctrl_cmd.ptz = ctrl_cmd.ptz * 6;//
YunTai_SetPwm(CONSTRAIN(ctrl_cmd.ptz + YunTai_MID, 2500,500)); //控制摄像头舵机
tim.c
htim3.Instance = TIM3;
htim3.Init.Prescaler = 8999; // htim3.Init.Prescaler = 8999; //预分频为9000
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 49;
时钟三控制舵机