![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
MCPWM.c
- Committer:
- Kovalev_D
- Date:
- 2017-08-16
- Revision:
- 214:4c70e452c491
File content as of revision 214:4c70e452c491:
#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; }