A basic structure of 8051 / 8052 code in C using Keil is given below. Kindly meet if you have nay ambiguity.
The C code is:
#include <AT89X52.H>
#include <stdio.h>
void main(void)
{
P0 = 0; // set all pins of Port0 to 0
P1 = 0; // set all pins of Port1 to 0
P2 = 0; // set all pins of Port2 to 0
P3 = 0; // set all pins of Port3 to 0
P1_2=1; // Set P1.2 high
//////////////////////////////////
// YOUR CODE HERE
/////////////////////////////////
while(1); // Infinite loop
}
Note: I have the code of Interrupt and Timers, but I am not posting it online right now. Please meet me and discuss it with me. Once you understand it, I will give the code to you.