![]() | ![]() | ![]() |
| |||||||
| General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion? |
![]() |
| | Tools |
| | #1 |
|
Hello, can some one plz verify my code below to be correct as I have no means of making sure it is at the moment. Thanks The task is to write a program that causes Port 1 to act as an 8-bit up counter. Include a 500msec delay (not including overhead) to slow the count sufficiently to observe in hardware. Use Timers to produce the delay. Here is my code (based on 12Mhz XTAL): CLR A START: MOV R2,#10 BACK: MOV TMOD,#01 ;Timer 1 Mode 1 MOV TL1,#0B0H ;TL1 = BOH, Low Byte MOV TH1,#3CH ;TH1 = 3CH, High Byte SETB TR1 ;Start Timer HERE: JNB TF1,HERE ;Stay here until timer rolls over CLR TR1 ;Stop Timer 1 CLR TF1 ;Clear timer flag DJNZ R2,BACK ;repeat this 10 times to get 500msec delay MOV P1,A ;mov A to P1 INC A SJMP START ;Calculations ;500msec = 500,000uS = 10 * 50000 = 65536 - 50000 = 3CB0H
__________________ "The people who cast the votes don't decide an election, the people who count the votes do." -Joseph Stalin Last edited by Frosty_47; 21st April 2009 at 04:32 AM. | |
| |
|
| Tags |
| 8051, counter, needed, verification |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Solenoid switch circuit verification | richacm | Electronic Projects Design/Ideas/Reviews | 21 | 15th June 2008 09:58 PM |
| 8051 simple counter | Jon1997 | 8051/8951 | 9 | 7th December 2006 06:27 AM |
| URGENT HELP NEEDED REGARDING 8051 | prasaddinkar | 8051/8951 | 3 | 22nd January 2006 06:33 PM |
| Help needed....8051 based LCD interface design | vik1501 | Electronic Projects Design/Ideas/Reviews | 1 | 19th November 2003 05:40 PM |
| using 8051 as pulse counter | waqar | Electronic Projects Design/Ideas/Reviews | 0 | 13th March 2003 05:06 PM |