 on 8051 programming in embedded C so learning outcomes will be you will be able to write a keel program using keel compiler program will be dealing with the bit addressable IO programming and you will be able to compare the assembly language programming approach with the C programming approach. So this is the problem statement we will take a door sensor is connected to P 1.1 so two pins of the mic port pins of the microcontroller are used so and buzzer is connected to P 1.7 so write a program so that when door sensors gives you the input it should when it opens it should sound a buzzer sound buzzer means you should generate a square wave and onto the port pin where the buzzer is connected. Now we will go to the programming part so now keel id when you open so let us create a project so let us create project on to C write so in this forum project I create a project with the name door sensor select the microcontroller we don't want any startup code for this so here you can start typing the code so we will be writing C program for accompanying this task include we include a file rhg51.h now two port pins we are using so define those port pin names sensor is connected to port 1.1 and buzzer is connected to port 1.7 now for generating a square wave we will require delay so right declare the delay function unsigned integer is the data type which will be the number of milliseconds delay you want to generate now we write main function now initially I switch off buzzer and assume sensor is giving you output as one now continuously you have to check for the sensor input so I write infinite loop while one so what you test is if sensor input is 0 so you have to turn on the buzzer so buzzer means you have to generate a square wave so what I make is buzzer is equal to 1 then I call delay let us say 200 millisecond delay and again I make buzzer is equal to 0 again I call that delay now you should declare that delay function I take two variables unsigned in ij and then I run a for loop for the parameter which is passed and in this for loop I just execute a program which takes one millisecond for its execution now whatever code is written you save this code give some name this is a c code so save it with the extension dot c add this file to the project build the target so your code is compiled successfully now you want to check the output for this particular code so you can run this particular code in the debug mode and what you can do is you can check the contents of the port so p 1.1 is connected so when that pin is open so you will find that this particular port pin is continuously going high and low it indicates that that buzzer will turn on so this is how you can write a program which will create a hex file for creating hex file you can click on the options for the target and here you create a hex file as well if you want to generate assembly language code for the c code which is returned go to the listing and there you enable assembly language code so click on okay again build the target now you can check the folder in which that c code was created so you will find hex file as well in the c code you can find a hex file created as well as this assembly language file so you can open this and here you'll find the equivalent assembly language code which is generated by the assembler these are the references used for this presentation thank you