go_away

Author Topic: PWM on P89V51RD2  (Read 2064 times)

0 Members and 1 Guest are viewing this topic.

Offline azadsagarTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
PWM on P89V51RD2
« on: February 12, 2011, 01:01:27 PM »
i am using P89V51RD2. i want to use hardware pwm. how can i implement that ?

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: PWM on P89V51RD2
« Reply #1 on: February 12, 2011, 02:59:58 PM »
P89V51RD2?

What does the data sheet say?
http://www.keil.com/dd/docs/datashts/philips/p89v51rd2.pdf
Section 7.8.4

Which IDE and programming language are your using?

Here are additional guides:
http://ics.nxp.com/support/documents/microcontrollers/?scope=P89V51RD2

Offline azadsagarTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: PWM on P89V51RD2
« Reply #2 on: February 15, 2011, 10:29:11 AM »
Datasheet is confusing me.
i recently started working on microcontroller dats y m nt familiar with technical terms.
i knw how to generate software pwm. (keil compiler)
problem with software pwm is that u can not generate 2 diffrent pwm using timer0 and timer1 may be coz of priorities.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: PWM on P89V51RD2
« Reply #3 on: February 15, 2011, 12:03:10 PM »
Is there a user's forum for the Keil tools and/or the P89V51RD2 processors?

How good is Keil's simulator? Maybe try getting the hardware PWM working in the sim.

I looked at the P89V51RD2 data sheet and I didn't see how the PWM hardware should work. There is a short section on registers for the PWM but no real explanation.


As for software PWM, if the two outputs you need are both at the same frequency then doing two different duty cycles is not that hard to do in the ISR. I have done this with PICs.

Offline azadsagarTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: PWM on P89V51RD2
« Reply #4 on: February 16, 2011, 10:58:28 AM »
Quote
void timer0(void) interrupt 1
{
   
   if(m1_state)
   {
       m1_enable=1;
      TH0=85;
      m1_state=0;
   }
   else
   {
      m1_enable=0
      THO=170;
      m1_state=1;
   }
   
 }

void timer1(void) interrupt 3
{
   if(m2_state)
   {
      m2_enable=1;
      TH0=100;
      m2_state=0;
   }
   else
   {
      TH0=155;
      m2_enable=0;
      m2_state=1;
   }
   
}

i checked above code in debuging mode for both the timers. n found timer1 interrupt never get executed this may be coz of interrupt priorities.
how can i generate two diffrent pwm ?
« Last Edit: February 16, 2011, 11:01:48 AM by azadsagar »

 


Get Your Ad Here

data_list