PWM Frequncy Problem

Discussion in 'The Projects Forum' started by rmrps, Nov 7, 2012.

  1. rmrps

    Thread Starter New Member

    Feb 24, 2012
    17
    0
    _FOSC(CSW_FSCM_OFF & XT_PLL8);
    _FWDT(WDT_OFF);
    _FBORPOR(PBOR_ON & MCLR_EN & PWRT_OFF);
    _FGS(CODE_PROT_ON);

    void Delay(unsigned int del);

    int main(void)
    {

    Delay(50000);
    Delay(50000);
    Delay(50000);
    Delay(50000);
    Delay(50000);
    TRISE=0x00;
    PORTE=0x00;
    PTCON=0x8004;
    PTMR=100;
    PTPER=199;
    IPC9bits.PWMIP=1;
    IFS2bits.PWMIF=0;
    IEC2bits.PWMIE=1;
    SEVTCMP=0x00;
    PWMCON1=0xFFF;
    PWMCON2=0x207;
    DTCON1=0x4C4C;
    DTCON2=0xFF;

    FLTACON=0xFF80;
    FLTBCON=0xFF80;
    OVDCON=0xFF00;
    PDC1=0x0A;
    PDC2=6553.6;


    while(1)
    {
    Delay(50000);
    Delay(50000);
    Delay(50000);
    }
    return (0);
    }

    void Delay(unsigned int del)
    {
    while(--del);
    }

    Hi friends this is my code for generating pwm pulses it is generating 275hz pulses but i want 20khz pulses there is no changes while changing PTPER value Same frequency only coming how to change frequency of pulses i am using 16Mhz PIC30F6010A controller please give me guidelines where to change the code for generating 20khz pulses thanks in advance
     
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    I'm not familiar with that device, but I know eeweb just posted an article on pwm for this family. It's in their design notes portion. I'd provide a link, but I'm on my phone at the moment...
     
Loading...