| ??? 09/23/11 23:19 Read: 263 times |
#183859 - use may use this code Responding to: Ralph Sac's previous message |
.equ OUTPIN,P2.1
.equ basecount,021h
.org 0000h
SJMP MAIN
.org 000bh ;Use timer0
LJMP TIMER_ROUT
.org 0070h
MAIN: MOV SP,#050H
MOV TMOD,#01H ;initialise timer 0 in 16 bit mode
mov IP,#02h ;give priority to timer0
mov TH0,#0ech ;5ms timer count loaded
mov TL0,#078h ;for 12 Mhz crystal
;The formula for deciding count is like
;(65535 - 5000) = 60535 here 5000 count for 5ms timer
;if you want to generate 1 ms timer then your formula should be
;(65525 - 1000) = 64535 and so on.
;So here we get count for 5ms timer = 60535D = EC78H =TH0TL0
setb TR0 ;turns on timer0
main1:
MOV IE,#082H ;1000 0010 Enables timer0 interrupt
sjmp main1
TIMER_ROUT:
;After Every 5ms time the timer interrupt jumps here
mov TH0,#0ech ;Reload timer count
mov TL0,#078h
inc basecount
mov a,basecount
cjne a,#50,skipchangestatus
cpl OUTPIN ;after every 50 * 5 = 250 ms compliment the OutputPin status
;So you get 2 low 2 high output status in 1 sec i.e 2 Hz freq.
mov basecount,#0 ;reset the base count
skipchangestatus:
reti ;return from timer interrupt
|
| Topic | Author | Date |
| Need a little help with frequency | Ralph Sac | 09/16/11 21:32 |
| use 89c52 | Maunik Choksi | 09/16/11 23:00 |
| "formulae" | Stefan KAnev | 09/16/11 23:34 |
| How to post legible source code - and text | Andy Neil | 09/17/11 10:43 |
| Legible source code | Ralph Sac | 09/17/11 16:09 |
| Not the whole message! | Andy Neil | 09/17/11 16:16 |
| Thanks Andy got little messed up | Ralph Sac | 09/17/11 17:00 |
| Already answered | Per Westermark | 09/17/11 18:43 |
| Still not understanding isr with tick | Ralph Sac | 09/23/11 21:33 |
| use may use this code | Maunik Choksi | 09/23/11 23:19 |
| Thanks for time | Ralph Sac | 09/24/11 18:43 |
| Rewrote Source Code for Metalink Assembler | Ralph Sac | 10/20/11 18:36 |
| keil assembler | Maunik Choksi | 10/20/11 23:25 |
No need for picture | Maunik Choksi | 10/21/11 07:36 |
| try | Stefan KAnev | 09/23/11 23:34 |
| the code above is a typical illustration of ... | Erik Malund | 09/24/11 07:35 |
| You are right | Ralph Sac | 09/24/11 18:39 |
| never too old | Erik Malund | 09/25/11 06:46 |
| Never too late to pick up a new trick | Per Westermark | 09/25/11 09:10 |
| One good trick ... | Richard Erlacher | 09/25/11 13:49 |
| Score -1 | Michael Karas | 09/25/11 19:59 |
| Learn one before Jumping head | Ralph Sac | 09/26/11 21:11 |
| Learning Assembler First | Michael Karas | 09/27/11 00:41 |
| I wholehardely concur. | Erik Malund | 09/27/11 08:03 |
| Thanks also you for your time | Ralph Sac | 09/24/11 18:46 |
| Here's something to try ... | Richard Erlacher | 09/24/11 14:57 |
| One suggession for higher frequency | Maunik Choksi | 09/26/11 02:00 |
| Remember no fractional part for | Per Westermark | 09/26/11 06:02 |
| Precise frequency | Mahmood Elnasser | 09/26/11 09:00 |
| I did not know that | Ralph Sac | 09/26/11 21:15 |
| 89c2051 | Stefan KAnev | 09/26/11 22:10 |
| When you wrote code | Ralph Sac | 09/27/11 12:10 |
| You normally always need to test - but may not need to debug | Per Westermark | 09/27/11 15:20 |
| it was example | Stefan KAnev | 09/27/11 15:20 |
| Ok then if I | Ralph Sac | 09/27/11 15:40 |
| try | Stefan KAnev | 09/27/11 21:54 |
| depends | Erik Malund | 09/28/11 06:54 |
| Testing Code | Michael Karas | 09/28/11 07:25 |
| In short | Per Westermark | 09/28/11 08:41 |
| someone said it better | Erik Malund | 09/28/11 09:03 |
| "Proven Product" Syndrome | Andy Neil | 09/29/11 01:24 |
| Did you ever look at that MIDE51 I previously mentioned? | Richard Erlacher | 10/21/11 01:39 |



