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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/09/07 12:18
Read: times


 
#148007 - running out of subject line ideas
Responding to: ???'s previous message
In reference to the two questions, when I said 'it worked', I meant loading the value of #080h progressed to load toff with #080h (actually #07Fh, but for this purpose and with all the other problems, im happy with this!)

when I said it just wont work, I meant sending the value of, say #0FEh I would expect the ontime to be 254/255 of the time. But it just isnt.

I've read further on the topics you pointed out and realised

a) I have not been clearing the carry bit at the right time
b) I needed to protect to acc and psw - I am not protecting R1 (aka ton) as it is meant to change to the value I am sending over the serial port. Is this wrong?

Finally, and this may seem quite dumb, but if I send #0fAh to the serial port does it take in each character one at a time and essentially load R1 with h each time?

For good measure, amended code attached :)

Time for sleep I think :) Russ, Ican't begin to thank you enough for this help - hopefully once I pass these initial hurdles my brain will be more in tune with the way these little gizmos operate :)



$mod652
org 0h
ljmp init

org 23h

PUSH PSW
PUSH ACC

JNB RI,$
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
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


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