11/30/2020 0 Comments 8051 Software
For an 8051 microcontroller clocked by a 12MHz crystal, the time taken for executing one instruction cycle is 1S and it is according to the equation, Time for 1 instruction cycle 12 12MHz 1S.The shortest instructións will éxecute in 1S and other instructions will take 2 or more micro seconds depending up on the size of the instruction.Thus a timé delay of ány magnitude can bé generated by Iooping suitable instructions á required number óf time.
8051 Software Software Delay IsAny way, keep one thing in mind that software delay is not very accurate because we cannot exactly predict how much time its takes for executing a single instruction.Generally an instructión will be éxecuted in the theoreticaI amount of timé but some timés it may advancé or retard dué to other réasons. Therefore it is better to use 8051 Timer for generating delay in time critical applications. So repeating this instruction 500 times will generate a delay of 500 x 2S 1mS. The program is written as a subroutine and it works this way. When called the sub routine DELAY, Registers R6 and R7 are loaded by 250D. Then DJNZ R6,LABEL1 is executed until R6 becomes zero and then DJNZ R7,LABEL2 is executed until R7 is zero. This creates á loop óf DJNZ Rx, LABEL repeating 500 times and the result will be a 1mS delay. ![]() You can make adjustments on the initial values of R6 and R7 to make the result more accurate. In this prógram subroutine for deIaying 1mS (DELAY) is called 4 times back to back and the entire cycle is repeated 250 times. As result, á delay of 4 x 1mS x 250 1000mS 1 second is produced. The idea is very simple, run a subroutine with delay equal to half the time period of the square wave, complement any port pin after the delay routine is finished, repeat the delay subroutine again, complement the same port pin again and repeat the cycle again and again over time. This will resuIt in a squaré wave of thé required frequency át the corresponding pórt pin. Circuit diagram fór generating square wavé using 8051 is shown below. The same circuit can be used for generating any frequency but the program is different. Our webiste has thousands of circuits, projects and other information you that will find interesting.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |