www.pudn.com > ads8364.rar > ADS8364_Pwm.c


//########################################################################### 
// 
// FILE:	DSP28_PieVect.c 
// 
// TITLE:	DSP28 Devices PIE Vector Table Initialization Functions. 
// 
//########################################################################### 
// 
//  Ver | dd mmm yyyy | Who  | Description of changes 
// =====|=============|======|=============================================== 
//  1.00| 06 Dec 2002 | T.H. | SLAA163 
//   
//########################################################################### 
#include "DSP28_Device.h" 
 
void PWM(void) 
{ 
//	EALLOW; 
	// Enable PWM pins 
//    GpioMuxRegs.GPAMUX.all = 0x0003; // EVA PWM 1-6  pins 
//    GpioMuxRegs.GPBMUX.all = 0x00FF; // EVB PWM 7-12 pins 
//    EDIS; 
     
// EVA Configure T1PWM, T2PWM, PWM1-PWM6  
// Step 1  Initalize the timers 
	// Initalize EVA Timer1  
	EvaRegs.T1PR = 0x0010;       // Timer1 period 
	EvaRegs.T1CMPR = 0x0000;     // Timer1 compare 
	EvaRegs.T1CNT = 0x0000;      // Timer1 counter 
    // TMODE = continuous up/down 
	// Timer enable 
	// Timer compare enable 
	EvaRegs.T1CON.all = 0x9042;    
 
 
// Step 2  Setup T1PWM and T2PWM 
	// Drive T1/T2 PWM by compare logic 
	EvaRegs.GPTCONA.all=0x0000; 
	// Polarity of GP Timer 1 Compare = Active low 
	EvaRegs.GPTCONA.all=0x0000; 
	// Polarity of GP Timer 2 Compare = Active high 
	EvaRegs.GPTCONA.bit.T2PIN = 2; 
 
// Step 3 Enable compare for PWM1-PWM6 
	EvaRegs.CMPR1 = 0x0008; 
    EvaRegs.ACTRA.all = 0x0002; 
	EvaRegs.DBTCONA.all = 0x0000; // Disable deadband 
    EvaRegs.COMCONA.all = 0x8200; 
 
    EvbRegs.ACTRB.all = 0x0006; 
	EvbRegs.DBTCONB.all = 0x0000; // Disable deadband 
    EvbRegs.COMCONB.all = 0xA600; 
 
} 	 
 
 
//=========================================================================== 
// No more. 
//===========================================================================