Skip to main content
Visitor II
March 2, 2005
Question

PWM 4

  • March 2, 2005
  • 3 replies
  • 779 views
Posted on March 02, 2005 at 13:05

PWM 4

    This topic has been closed for replies.

    3 replies

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 11:57

    We just discovered that there is a problelm with PWM4 (variable period) channel on the uPSD processors. PWM4 does not work well when the prescaler value (PRESCALER1) are set to 2^n (i.e. 2,4,8,16 ... 2^n).

    fafaneAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 11:57

    Hello,

    I seem to have some problems with the port PWM4. First, I have to say that the drivers given by St don't work. I had to change the formula for the PWMs[0:3] from :

    PWM_prescaler = (unsigned int) ( (((unsigned int) FREQ_OSC) / 2) / PWM_freq

    ;

    if (PWM_prescaler != 0) PWM_prescaler--; // subtract 1 if not zero

    to :

    PWM_prescaler = (unsigned short)((FREQ_OSC/512)/PWM_freq

    ;

    ( Hope that it may help )

    Then, unfortunately, I tried the code below to make the PWM4 work but the result were quite different from what i was expecting. ( No signal at all, or some but with different frequencies or duty_cycle )

    define FREQ_OSC 36000000

    void uPSD_PWM_Variable_8bit(unsigned char PWM_Period, unsigned char PWM_PulseWidth)

    {

    PWM4P = PWM_Period; // Load period value

    PWM4D = PWM_PulseWidth; // Load pulse width value

    }

    void Init_PWM4(unsigned long PWM_freq)

    {

    unsigned short PWM_prescaler;

    P4SFS |= 0x80; // Turn ON I/O port for the variable PWM channel

    PWMCON |= 0x30; // Set variable PWM to push-pull & enable PWM

    PWM_prescaler = (unsigned short)((FREQ_OSC/2L)/PWM_freq);

    PWM_prescaler--;

    PSCL1L = PWM_prescaler & 0x00ff;

    PSCL1H = (PWM_prescaler >>

    ;

    }

    Then

    //Init_PWM4(600); uPSD_PWM_Variable_8bit(0xFF, 0x20); in order to have a signal that would use all the period and a pulse with a duty cycle of about 10%.

    Thanx a lot in advance

    Fafane

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 11:57

    Can you tell me anymore about this problem with the PWM4 on uPSD3200 ?

    I'm using this function on a uPSD3234A. A problem occurs when the Prescaler contains 0080h. All other values appear to give an expected output from PWM4, but this value yields an inconsistant result, where the output pulse determined by PWM4P is correct, but the pulse determined by PWM4W is about 50 times what it should be.

    Are there any published documents concerning this problem ?

    Is there a work around ?

    Thanks..