SOC EQU P2.6 EOC EQU P2.5 OE EQU P2.4 ALE EQU P2.3 ADDR_C EQU P2.2 ADDR_B EQU P2.1 ADDR_A EQU P2.0ORG 0000H MOV P1, #0FFH SETB P2.5 CLR SOC CLR OE CLR ALE AGAIN: CLR ADDR_C CLR ADDR_B CLR ADDR_A SETB SOC SET ALE ACALL DELAY CLR SOC CLR ALE BACK: JB EOC BACK HERE: JNB EOC HERE SETB OE MOV A,P1 ACALL CONVERSION ACALL DISPLAY AGAIN: SJMP AGAIN.
|
ORG 000H MOV P1, #00H call squarwave call triwave call stairwave jmp repeat squarwave: MOV P1,#FFH call delay2sec MOV P1,#00H call delay2sec ret triwave: MOV R7,#00H triwave1: MOV P1,R7 inc R7 cjne R7, #FFH, triwave1 MOV R7, #FFh Triwave2: MOV P1, R7 djnz R7, triwave2 RET Stairwave: MOV P1, #00H call delay2sec MOV P1, #20H Call delay2sec MOV P1, #40H Call delay2sec RET delay1sec: MOV R0,#10 del2 : MOV R1,#250 del1: MOV R2,#250 DJNZ R2,$ DJNZ R1,del2 DJNZ R0,del1 RET Delay2sec: MOV R0,#20 del2 : MOV R1,#250 del1: MOV R2,#250 DJNZ R2,$ DJNZ R1,del21 DJNZ R0,del22 RET END
|
M0 | M1 | Mode | Operating Mode |
0 | 0 | 0 | 13-bit timer mode. 8 bit timer/counter THx and TLx as –bit prescalar |
0 | 1 | 1 | 16-bit timer mode , 16-bit timers/counters THx and TLx as 5-bit prescalar |
1 | 0 | 2 | 8-bit auto reload mode, 8-bit auto reload timer/counter; THx holds a value which is to be reloaded into TLx each time it overflows |
1 | 1 | 3 | Split timer mode |
TF1 | TR1 | TF0 | TR0 | IE1 | IT1 | IE0 | IT0 |
Bit | Symbol | Functions |
7 | TF1 | Timer1 overflow flag. Set when timer rolls from all 1’s to 0 |
6 | TR1 | Timer 1 run control bit. Set to 1 by programmer to enable timer to count. |
5 | TF0 | Timer 0 overflow flag |
4 | TR0 | Timer 0 run control bit |
3 | IE1 | External Interrupt 1 edge flag |
2 | IT1 | External Interrupt 1 signal type control bit |
1 | IE0 | External Interrupt 0 edge flag |
0 | IT0 | External Interrupt 0 signal type control bit |
Bit Details | High Value(1) | Low Value(0) |
C/T | Configure for the Counter operations | Configure for the Timer operations |
Gate (G) | Timer0 or Timer1 will be in RunMode when TRX bit of TCON register is high. | Timer0 or Timer1 will be in RunMode when TRX bit of TCON register is high and INT0 or INT1 is high. |
Bit Details | 00 | 01 | 10 | 11 |
M1 M0 | This is for Mode 0. (8-bit timer/counter, with 5-bit pre-scaler) | This is Mode 1. (16-bit timer/counter) | This is Mode 3 (8-bit auto reload-timer/counter) | This is Mode 3 (The function depends on Timer0 or Timer1) |