u16 arrdata=9999;
u16 dutydata;
//speeddata = 0x000A;
speeddata = ((u8)Uart1_data[5] << 8) | (u8)(Uart1_data[4]);
switch (speeddata) {
case 0x0008: arrdata = 655; break;//8//15.26hz
case 0x000A: arrdata = 600; break;//10//16.67hz
case 0x000F: arrdata = 370; break;//15//27.03hz
case 0x0014: arrdata = 300; break;//20//33.33hz
case 0x0019: arrdata = 200; break;//25//50hz
case 0x001E: arrdata = 160; break;//30//62.5hz
case 0x0023: arrdata = 145; break;//35//68.96hz
case 0x0028: arrdata = 125; break;//40//80hz
case 0x002D: arrdata = 109; break;//45//91.74hz
case 0x0032: arrdata = 100; break;//50//100hz
case 0x0037: arrdata = 91; break;//55//109.28hz
case 0x003C: arrdata = 83; break;//60//120.47hz
case 0x0041: arrdata = 76; break;//65//131.57hz
case 0x0046: arrdata = 70; break;//70//142.84hz
case 0x004B: arrdata = 65; break;//75//153.83hz
case 0x0050: arrdata = 60; break;//80//166.65hz
default: break;
}
TIM_Cmd(TIM3,DISABLE);
TIM_PrescalerConfig(TIM3,7200,arrdata);
TIM_Cmd(TIM3,ENABLE);
dutydata=(arrdata+1)/2;
TIM_SetCompare3(TIM3, dutydata); |