本帖最后由 meiyouusername 于 2020-6-2 15:41 编辑
void TMR2_Initialize (void)
{
//TMR2 0;
TMR2 = 0x00;
//Period = 0.000256 s; Frequency = 2000000 Hz; PR2 511;
PR2 = 0x1FF;
//TCKPS 1:1; T32 16 Bit; TON enabled; TSIDL disabled; TCS FOSC/2; TGATE disabled;
T2CON = 0x8000;
}
void TMR3_Initialize (void)
{
//TMR3 0;
TMR3 = 0x00;
//Period = 0.000256 s; Frequency = 2000000 Hz; PR3 511;
PR3 = 0x1FF;
//TCKPS 1:1; TON enabled; TSIDL disabled; TCS FOSC/2; TGATE disabled;
T3CON = 0x8000;
}
void OC1_Initialize (void)
{
// OC1RS 222;
OC1RS = 60;
// OC1R 100;
OC1R = 10;
// OCSIDL disabled; OCM Single Compare Single-Shot mode: high to low; OCTSEL TMR2;
OC1CON = 0x0E;
}
void pwmInit(void) ///??1 ??????pwm ?? ?T3????T2 +OC1 ??PWM?
{
PMD1 = 0x00FF;
TRISAbits.TRISA6 =0;
LATAbits.LATA6 =0;
OC1_Initialize ();
TMR2_Initialize();
TMR3_Initialize();
}
|