cancel
Showing results for 
Search instead for 
Did you mean: 

PWM 4

fafane
Associate
Posted on March 02, 2005 at 13:05

PWM 4

3 REPLIES 3
joseph2399
Associate II
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).

fafane
Associate
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

tim239955
Associate II
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..