亲爱的SIRSI希望使用PIN RC1上的PWM。我没有工作,这张照片(我试过2天了)。我当然使用MCC和数据表。PSS2AC低;CCP2AS禁用;ECCP2AS=0x00;//P2RSEN自动_重启;P2DC 0;PWM2CON=0x80;//PWM2CON=0x80;//PWM2CON=0X2CON=0x80;//STRM2STRM2CON P2D_2P2D_to_端口;STR2C P2C P2C_P2C_2C_to_端口;STR2C P2C_P2C_P2C_to_端口;STR2B P2B_P2B_to_端口;STR2A P2B P2B_P2B_P2B_to_端口;STR2A P2B P2A_to_端口;STR2A P2A_开始_端口;STR2SYNC start start_start_CCPR2H=0x00;通知MUX PINS设置正确:#pragma config CCP2MX=PORTC1//CCP2 MUX bit->CCP2输入/输出与RC1#pragma config PBADEN=ON//PORTB A/D Enable bit->PORTB<5:0>pins被配置为复位#pragma c上的模拟输入通道onfig CCP3MX=PORTB5//P3A/CCP3多比特->P3A/CCP3输入/输出与RB5#pragma config HFOFST=ON//HFINTOSC快速启动>HFINTOSC输出多路复用,并且就绪状态不被振荡器稳定状态#pragma config T3CMX=PORTC0//
timer3时钟输入多比特->T3CKI i延迟s在RC0#pragma配置P2BMX=PORTC0//ECCP2 B上输出多路位->P2B在RC0#pragma配置MCLRE=EXTMCLR//MCLR Pin Enable bit->MCLR pin启用,RE3输入pin禁用设置定时器4:void TMR4_Initialize(void){//将TMR4设置为在用户接口//T4CKPS 1:1;T4O中选择的选项UTP1:4;TMR4ON;T4CON= 0x18;//PR4 249;PR4= 0xF9;//TMR4 0;TMR4= 0x00;/ /清除IF标志。PIR5bits.TMR4IF=0;//Start TMR4 TMR4_StartTimer();}使用XC08实际转换与PIckit3。请帮助我,否则我会变态。谢谢Andy
以上来自于百度翻译
以下为原文
Dear Sirs
I want to use the PWM on PIN RC1. I did it not working, this lausi PIC (-;
(i tried 2 days now). I use the MCC and the Datasheet of course.
Following Setting:
INitialising PWM2:
void EPWM2_Initialize (void)
{
// Set the PWM to the options selected in MPLAB(c) Code Configurator
// CCP2M P2A,P2C: active low; P2B,P2D: active high; DC2B 3; P2M0 single;
CCP2CON = 0x3E;
// CCP2ASE operating; PSS2BD low; PSS2AC low; CCP2AS disabled;
ECCP2AS = 0x00;
// P2RSEN automatic_restart; P2DC 0;
PWM2CON = 0x80;
// STR2D P2D_to_port; STR2C P2C_to_port; STR2B P2B_to_port; STR2A P2A_to_port; STR2SYNC start_at_begin;
PSTR2CON = 0x00;
// CCPR2L 124;
CCPR2L = 0x7C;
// CCPR2H 0;
CCPR2H = 0x00;
// Selecting Timer4
CCPTMRS0bits.C2TSEL = 0x1;
}
Noticed the MUX PINS Set correct:
#pragma config CCP2MX = PORTC1 // CCP2 MUX bit->CCP2 input/output is multiplexed with RC1
#pragma config PBADEN = ON // PORTB A/D Enable bit->PORTB<5:0> pins are configured as analog input channels on Reset
#pragma config CCP3MX = PORTB5 // P3A/CCP3 Mux bit->P3A/CCP3 input/output is multiplexed with RB5
#pragma config HFOFST = ON // HFINTOSC Fast Start-up->HFINTOSC output and ready status are not delayed by the oscillator stable status
#pragma config T3CMX = PORTC0 // Timer3 Clock input mux bit->T3CKI is on RC0
#pragma config P2BMX = PORTC0 // ECCP2 B output mux bit->P2B is on RC0
#pragma config MCLRE = EXTMCLR // MCLR Pin Enable bit->MCLR pin enabled, RE3 input pin disabled
Setting Timer 4:
void TMR4_Initialize(void)
{
// Set TMR4 to the options selected in the User Interface
// T4CKPS 1:1; T4OUTPS 1:4; TMR4ON off;
T4CON = 0x18;
// PR4 249;
PR4 = 0xF9;
// TMR4 0;
TMR4 = 0x00;
// Clearing IF flag.
PIR5bits.TMR4IF = 0;
// Start TMR4
TMR4_StartTimer();
}
Using XC08 actual VErsion with PIckit3.
Please help me, otherwise i get freaky.
Thanks Andy
0