![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
Diff: MCPWM.c
- Revision:
- 214:4c70e452c491
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MCPWM.c Wed Aug 16 09:00:25 2017 +0000 @@ -0,0 +1,35 @@ +#include "stdlib.h" +//#include "math.h" +#include "LPC17xx.h" +#include "Global.h" +unsigned int fhz=350,T_vib=5,T_vib_1=10000,T_vib_2=100000,AmpP=3000,err; +float T_vibP=10000, F_vib=258000; + + +void InitMCPWM(void) +{ + // Power up MCPWM + + LPC_SC->PCONP |= 1<<17; + LPC_SC->PCLKSEL1 |= 1<<30; + + + // Configuring P1.25 and P1.28 as MC1A and MC2A + LPC_PINCON->PINSEL3 |= (1<<18) | (1<<24); + LPC_MCPWM->CON_SET |= 0x40070707; + LPC_MCPWM->CAPCON_SET |= 0x1c0000; + + // Start MCPWM channels 1 and 2 and POLA = 1 + LPC_MCPWM->CON_CLR = 0xffffffff; + LPC_MCPWM->CON_SET = (0<<10) | (1<<18) | (1<<16) | (1<<8) | (1<<9) | (1<<17); +} + +void ReVib(void) +{ Gyro.AmpPer = ((Gyro.Amp*100)>>17); + + F_vib=(103200000<<5)/((Gyro.Frq)>>10);//периуд вибро. + T_vibP = F_vib/10000; + + LPC_MCPWM->LIM1 = F_vib; + LPC_MCPWM->LIM2 = F_vib; +} \ No newline at end of file