请问定时器时钟分频是否只与这里的配置有关,应该没有其他相关了。以下是程序,keil的debug里观察P1波形,变动频率却是1HZ,用的是C8051F310晶振24.5MHZ。配置为系统时钟的48分频,可实际为系统时钟32分频,求解!谢谢各位大神!
ORG 0000H
LJMP MAIN
ORG 000BH ;定时器T0中断入口
LJMP IT0P
ORG 0200H
MAIN: LCALL Init_Device ;设备初始化
MOV SP, #60H ;置堆栈指针
MOV TMOD,#01H ;确定工作方式
SETB EA ;允许中断
SETB ET0
LOOP2: MOV TH0,#06H
MOV TL0,#0C6H
MOV R0, #0
CLR A
LOOP: SETB TR0
CJNE A, #8EH, LOOP
MOV P1, A
CLR TR0
SJMP LOOP2
IT0P: MOV TH0,#06H
MOV TL0,#0C6H
CLR P0.7 ;选择数码管最末位管
CLR P0.6
CLR A
MOV A, R0
MOV DPTR, #TABLE
MOVC A, @A+DPTR
MOV P1, A
INC R0
RE
ti
ORG 0040H
TABLE: DB 0FCH,60H,0DAH,0F2H,66H,0B6H
DB 0BEH,0E0H,0FEH,0F6H,0EEH,0FEH
DB 9CH,0FCH,9EH,8EH
;------------------------------------
;- Generated Initialization File --
;------------------------------------
$include (C8051F310.inc)
public Init_Device
INIT SEGMENT CODE
rseg INIT
; Peripheral specific initialization functions,
; Called from the Init_Device label
PCA_Init:
anl PCA0MD, #0BFh
mov PCA0MD, #000h
ret
Timer_Init:
mov TMOD, #001h
mov CKCON, #002h
ret
Port_IO_Init:
mov XBR1, #040h
ret
Interrupts_Init:
mov IT01CF, #021h
ret
; Initialization function for device,
; Call Init_Device from your main program
Init_Device:
lcall PCA_Init
lcall Timer_Init
lcall Port_IO_Init
lcall Interrupts_Init
ret
end
用CONFIG2配置的
一周热门 更多>