Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/10/07 14:23
Read: times


 
#148042 - Some comments
Responding to: ???'s previous message
$mod652
org 0h
ljmp init

org 23h         ; Only OK as long as interrupt 5 is unused, otherwise put only an ljmp at this address

PUSH PSW
PUSH ACC

JNB RI,$        ; Never put a waiting loop inside an ISR !
MOV A,S0BUF
MOV TON,A
CLR RI

POP ACC
POP PSW

reti

org 100h
;------------------
init:

SETB ES0 ; enable serial interrupt
MOV S0CON,#50H ; SET TO SERIAL MODE1
MOV TMOD,#20H ; SET TIMER 1 TO MODE 2 (8 BIT AUTO RELAOD)
MOV TH1,#253 ;SET BAUD TO 9600
SETB TR1
SETB EA

ton equ r1 ;on time 
toff equ r2 ; off time
mov ton, #080h ; manually set on time to 080h (50%)
jmp loop
;------------------

;------------------
loop:
call makeon
setb p2.0
call delayon
clr p2.0
call makeon     ; Better not a second time, you'll get irregular periods
call delayoff
jmp loop
;------------------

;------------------
makeon:

clr c ; clear carry bit for subtraction operation
mov a,#0FFh
subb a,ton ;subtract ton from acc (255) therefore giving us the value of toff
mov toff,a ;load up toff with the result of the subb
ret
;------------------


;------------------
delayon: ;this function loads acc with the value of ton then decrements till its zero and returns
mov a,ton 
delayona:
dec a
jnz delayona
ret
;------------------

;------------------
delayoff: ;this function loads acc with the value of ton then decrements till its zero and returns
mov a,toff
delayoffa:
dec a
jnz delayoffa
ret
;------------------


end<pre>




List of 22 messages in thread
TopicAuthorDate
PWM code thoughts and help?            01/01/70 00:00      
   Some thoughts and help            01/01/70 00:00      
      very good help Russ            01/01/70 00:00      
      cheers!            01/01/70 00:00      
      character for 32            01/01/70 00:00      
         Good            01/01/70 00:00      
      A & R4 fatal occurence            01/01/70 00:00      
         Info on interrupts            01/01/70 00:00      
            Right next to me...            01/01/70 00:00      
               Aha            01/01/70 00:00      
      tell the truth!            01/01/70 00:00      
         Take a few deep breaths            01/01/70 00:00      
            no arteries popping            01/01/70 00:00      
   hows this? :)            01/01/70 00:00      
      Better, but still has problems            01/01/70 00:00      
         running out of subject line ideas            01/01/70 00:00      
            re: running out of subject line ideas :)            01/01/70 00:00      
            Some comments            01/01/70 00:00      
   Interrupts and shared resources            01/01/70 00:00      
   a thought - if it is help is up to you            01/01/70 00:00      
   More on the PWM program            01/01/70 00:00      
      Purpose of my question            01/01/70 00:00      

Back to Subject List