Dmitry Kovalev / Mbed 2 deprecated LGstaandart

Dependencies:   mbed

Fork of LG2 by Dmitry Kovalev

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MCPWM.c Source File

MCPWM.c

00001 #include "stdlib.h"
00002 //#include "math.h"
00003 #include "LPC17xx.h"
00004 #include "Global.h"
00005 unsigned int fhz=350,T_vib=5,T_vib_1=10000,T_vib_2=100000,AmpP=3000,err;
00006 float T_vibP=10000, F_vib=258000;
00007 
00008 
00009 void InitMCPWM(void)
00010 { 
00011           // Power up MCPWM
00012 
00013    LPC_SC->PCONP |= 1<<17;
00014    LPC_SC->PCLKSEL1 |= 1<<30;
00015  
00016  
00017           // Configuring P1.25 and P1.28 as MC1A and MC2A
00018   LPC_PINCON->PINSEL3 |= (1<<18) | (1<<24); 
00019   LPC_MCPWM->CON_SET |= 0x40070707;
00020   LPC_MCPWM->CAPCON_SET |= 0x1c0000;
00021 
00022           //  Start MCPWM channels 1 and 2 and POLA = 1
00023     LPC_MCPWM->CON_CLR = 0xffffffff;
00024     LPC_MCPWM->CON_SET = (0<<10) | (1<<18) | (1<<16) | (1<<8) | (1<<9) | (1<<17); 
00025 }
00026 
00027 void ReVib(void)
00028 {     
00029 
00030         Gyro.AmpPer = ((Gyro.Amp*100)>>17);
00031         
00032         F_vib=(103200000<<5)/((Gyro.Frq)>>10);//периуд вибро.
00033         T_vibP = F_vib/10000;
00034         
00035         LPC_MCPWM->LIM1 = F_vib;
00036         LPC_MCPWM->LIM2 = F_vib;
00037 }