I am trying to output a 500khz clock out P1.0
I am running a 89C450 at 29.491mhz.
The serial routine using timer1 works fine.
I have the following test code:
;
; ***** TEST ROUTINE FOR TIMER 2 CLOCK OUT ON P1.0 *****
;
pcon equ 87h ;address of PCON register
t2con equ 0c8h
t2mod equ 0c9h
rcap2l equ 0cah
rcap2h equ 0cbh
org 0000h
ljmp start
org 0100h ;allways start ROM program at 0100h
start: nop
mov rcap2h,#0ffh
mov rcap2l,#0f1h
mov a,t2con ;get current t2con value
anl a,0fch ;clear bits 0 and 1 to set for 16bit reload
mov t2con,a ;write back to t2con
mov a,t2mod ;get current t2mod value
orl a,#02h ;sets bit 1 to enable p1.0 output
mov t2mod,a ;write back to t2mod
mov a,t2con ;get current t2con value
orl a,#04h ;sets bit 2 to enable timer2
mov t2con,a ;write back to t2con
mov scon,#50h ;set serial port 0 to mode 1 with rec enabled
mov tmod,#20h ;set timer 1 as auto-reload 8-bit timer
mov th1,#0fch ;baud rate equals 19200b at 29.491mhz
mov ie,#80h ;do not enable serial interupt
mov tcon,#40h ;start timer 1
setb ea ;global enable interrupts
setb p3.6 ;set pull-up on WR
setb p3.7 ;set pull-up on RD
clr ri ;ensure that receive interupt flag is cleared
clr ti
mov a,#00h ;clear Acc
mov p1, a ;clear port 1
loop: jnb ri,loop
mov a,sbuf ;get serial data
clr ri
mov sbuf,a ;echo back
jnb ti,$
ljmp loop
end
P1.0 goes low, stays low, and never get clock out?
What am I doing wrong? Please help me.
I am running a 89C450 at 29.491mhz.
The serial routine using timer1 works fine.
I have the following test code:
;
; ***** TEST ROUTINE FOR TIMER 2 CLOCK OUT ON P1.0 *****
;
pcon equ 87h ;address of PCON register
t2con equ 0c8h
t2mod equ 0c9h
rcap2l equ 0cah
rcap2h equ 0cbh
org 0000h
ljmp start
org 0100h ;allways start ROM program at 0100h
start: nop
mov rcap2h,#0ffh
mov rcap2l,#0f1h
mov a,t2con ;get current t2con value
anl a,0fch ;clear bits 0 and 1 to set for 16bit reload
mov t2con,a ;write back to t2con
mov a,t2mod ;get current t2mod value
orl a,#02h ;sets bit 1 to enable p1.0 output
mov t2mod,a ;write back to t2mod
mov a,t2con ;get current t2con value
orl a,#04h ;sets bit 2 to enable timer2
mov t2con,a ;write back to t2con
mov scon,#50h ;set serial port 0 to mode 1 with rec enabled
mov tmod,#20h ;set timer 1 as auto-reload 8-bit timer
mov th1,#0fch ;baud rate equals 19200b at 29.491mhz
mov ie,#80h ;do not enable serial interupt
mov tcon,#40h ;start timer 1
setb ea ;global enable interrupts
setb p3.6 ;set pull-up on WR
setb p3.7 ;set pull-up on RD
clr ri ;ensure that receive interupt flag is cleared
clr ti
mov a,#00h ;clear Acc
mov p1, a ;clear port 1
loop: jnb ri,loop
mov a,sbuf ;get serial data
clr ri
mov sbuf,a ;echo back
jnb ti,$
ljmp loop
end
P1.0 goes low, stays low, and never get clock out?
What am I doing wrong? Please help me.