This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

.Set PWM o/p pin in AT89C51CC01

Hello all,
I am currently working with AT89C51CC01.One can see the Datasheet from the following link.

www.atmel.com/.../doc4129.pdf

My work is to make program which gives PWM as output. Just check this code.
#include <stdio.h>
#include "reg_c51.h"

#define PWMPIN P1_0

unsigned char pwm_width;
void pwm_setup();
void timer0();

void main(void)
{

pwm_setup();
PWMPIN = P1_7;
//timer0();
while(1);
}

void pwm_setup()
{ TMOD = 0;
pwm_width = 200;
EA = 1;
ET0 = 1;
TR0 = 1;
}

void timer0() interrupt 1
{ if(!F0) //Start of High level
{ F0 = 1; //Set flag
PWMPIN = P1_7; //Set PWM o/p pin
TH0 = pwm_width; //Load timer
TF0 = 0; //Clear interrupt flag
return; //Return
} else //Start of Low level
{ F0 = 0; //Clear flag
PWMPIN = 0; //Clear PWM o/p pin
TH0 = 255 - pwm_width; //Load timer
TF0 = 0; //Clear Interrupt flag
return; //return
} }

I had write this code in Keiluvision4 and after making hex file, i open hex file using Flip 3.4.1 and load whole

file into controller and check the o/p using oscilloscope.
I set p1_7 pin for PWM o/p, but when i test this program then it gives nothing on p1_7 pin.
wht is the problem in this program?
Pls give ur advice for this problem.

Thank u in advance.

0