;Description:
;1. This program uses AT89C2051 microcontroller to drive DA converter AD7545 to output single-phase 50Hz sine wave signal.
;2. Output a square wave signal in phase with the sine wave at port P3.5. The square wave signal can be used to
cut off the sine signal at the zero crossing of the sine signal. ;
;Author: Free Zheng ;
;************************************************************************;
DACL EQU P1 ;Define the low 8-bit data output port
DACH EQU P3 ;Define the high 8-bit data output port
DASHUT EQU 00H ;Data
LED EQU P3.7 ;Define the indicator light output port
ORG 00H ;Start address
AJMP MAIN ;Jump to main program
ORG 03H ;External interrupt 0 entry
RETI ;Interrupt return
ORG 0BH ;Timer 0 interrupt entry
RETI ;Return directly
ORG 13H ;External interrupt 1 entry
RETI ;Return directly
ORG 1BH ;Timer 1 interrupt entry
RETI ;Return directly
ORG 23H ;Serial port interrupt entry
RETI ;Return directly
ORG 30H ; Main program entry
MAIN: MOV DACL,#DASHUT ;Data output port output 0
MOV DACH,#DASHUT ;Data output port output 0
MOV R0,#0 ;R0=0
MOV R1,#0 ;R1=0
MOV R2,#40H ;R2=40H
START:
NOP ;No operation, used for delay
NOP
NOP
NOP
NOP
NOP
LABEL3:
MOV DPTR,#SIN1 ;Sine function table address
MOV A,R0 ;Send the data in R0 to the accumulator
MOV DPL,R0 ;Data pointer register low 8 bits
MOVC A,@A+DPTR ;Look up the table
MOV R7,A ;The value is sent to R7
INC R0 ;Register plus 1
MOV A,R0 ;Send the data in R0 to the accumulator
MOVC A,@A+DPTR ;Look up
the table MOV DACL,A ;The value is output to the low 8-bit data output port
MOV A,R7 ;Send the first lookup value to the accumulator
CJNE R0,#100,SQUAREL ;If the value of R0 is not equal to 100, jump to the SQUAREL label to execute
MOV R2,#0F0H ;Otherwise send 0FH to R2
JMP SQ1 ;Jump to SQ1 label and execute
SQUAREL:
NOP ;No operation, used for delay
NOP
NOP
SQ1:
ORL A,R2 ;Add the content of R2 to the accumulator
MOV DACH,A ;Send the content of the accumulator to the high 8-bit data output port
ACALL DELAY ;Call delay program
CJNE R0,#200,START ;If the value of R0 is not equal to 200, jump to the START label and execute
NOP ;No operation
JMP LABLE1 ;Jump to LABLE1 label and execute
NEXT:
NOP ;No operation, used for delay
NOP
NOP
NOP
NOP
NOP
LABEL4:
MOV DPTR,#SIN2 ;
MOV A,R1
MOV DPL,R1
MOVC A,@A+DPTR
MOV R6,A
INC R1
MOV A,R1
MOVC A,@A+DPTR
MOV DACL,A
MOV A,R6
CJNE R1,#100,SQUAREH
MOV R2,#00H
JMP SQ2
SQUAREH:
NOP
NOP
NOP
SQ2:
ORL A,R2
MOV DACH,A
ACALL DELAY
CJNE R1,#200,NEXT
NOP
JMP LABLE2
NOP
NOP
LJMP MAIN
LABLE1:
MOV R0,#0
JMP LABEL4
NOP
NOP
LJMP MAIN
LABLE2:
MOV R1,#0
JMP LABEL3
NOP
NOP
LJMP MAIN
DELAY:
MOV R3,#8
DEL1:
DJNZ R3,DEL1
RET
NOP
NOP
LJMP MAIN
ORG 100H
SIN1:
DW 2048, 2080, 2112, 2144, 2177, 2209, 2241, 2273, 2305, 2337, 2368, 2400, 2432, 2463, 2495, 2526, 2557, 2588, 2619, 2650
DW 2681, 2711, 2742, 2772, 2802, 2832, 2861, 2891, 2920, 2949, 2978, 3006, 3035, 3063, 3091, 3118, 3145, 3172, 3199, 3226
DW 3252, 3278, 3303, 3328, 3353, 3378, 3402, 3426, 3450, 3473, 3496, 3519, 3541, 3563, 3584, 3605, 3626, 3646, 3666, 3686
DW 3705, 3724, 3742, 3760, 3777, 3794, 3811, 3827, 3843, 3858, 3873, 3887, 3901, 3915, 3928, 3940, 3952, 3964, 3975, 3986
DW 3996 , 4005 , 4015 , 4023 , 4032 , 4039 , 4047 , 4053 , 4060 , 4066 , 4071 , 4076 , 4080 , 4084 , 4087 , 4090 , 4092 , 4094 , 4095 , 4095
DW 4095 , 4095 , 4095 , 4094 , 4092 , 4090 , 4087 , 4084 , 4080 , 4076 , 4071 , 4066 , 4060 , 4053 , 4047 , 4039 , 4032 , 4023 , 4015 , 4005
DW 3996, 3986, 3975, 3964, 3952, 3940, 3928, 3915, 3901, 3887, 3873, 3858, 3843, 3827, 3811, 3794, 3777, 3760, 3742, 3724
DW 3705, 3686, 3666, 3646, 3626, 3605, 3584, 3563, 3541, 3519, 3496, 3473, 3450, 3426, 3402, 3378, 3353, 3328, 3303, 3278
DW 3252, 3226, 3199, 3172, 3145, 3118, 3091, 3063, 3035, 2711
DW 2 681, 2650, 2619, 2588, 2557, 2526, 2495, 2463, 2432, 2400, 2368, 2337, 2305, 2273, 2241, 2209, 2177, 2144, 2112, 2080
ORG 300H
SIN2:
DW 2048 , 2016 , 1984 , 1952 , 1919 , 1887 , 1855 , 1823 , 1791 , 1759 , 1728 , 1696 , 1664 , 1633 , 1601 , 1570 , 1539 , 1508 , 1477 , 1446
DW 1415 , 1385 , 1354 , 1324 , 1294 , 1264 , 1235 , 1205 , 1176 , 1147 , 1118 , 1090 , 1061 , 1033 , 1005 , 978 , 951 , 924 , 897 , 870
DW 844 , 818 , 793 , 768 , 743 , 718 , 694 , 670 , 646 , 623 , 600 , 577 , 555 , 533 , 512 , 491 , 470 , 450 , 430 , 410
DW 391 , 372 , 354 , 336 , 319 , 302 , 285 , 269 , 253 , 238 , 223 , 209 , 195 , 181 , 168 , 156 , 144 , 132 , 121 , 110
DW 100 , 91 , 81 , 73 , 64 , 57 , 49 , 43 , 36 , 30 , 25 , 20 , 16 , 12 , 9 , 6 , 4 , 2 , 1 , 0
DW 0 , 0 , 1 , 2 , 4 , 6 , 9 , 12 , 16 , 20 , 25 , 30 , 36 , 43 , 49 , 57 , 64 , 73 , 81 , 91
DW 100 , 110 , 121 , 132 , 144 , 156 , 168 , 181 , 195 , 209 , 223 , 238 , 253 , 269 , 285 , 302 , 319 , 336 , 354 , 372
DW 391 , 410 , 430 , 450 , 470 , 491 , 512 , 533 , 555 , 577 , 600 , 623 , 646 , 670 , 694 , 718 , 743 , 768 , 793 , 818
DW 844 , 870 , 897 , 924 , 951 , 978 , 1005 , 1033 , 1061 , 1090 , 1118 , 1147, 1176, 1205, 1235, 1264, 1294, 1324, 1354, 1385 759
, 1791, 1823, 1855, 1887, 1919, 1952, 1984, 2016
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
NOP
NOP
LJMP MAIN
END
Previous article:PC2004 LCM Driver
Next article:SSD1963 Example Program
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Can you tell me what the Cf2 capacitor does in the circuit? Thanks!
- Top 10 hot technologies in 2019: 5G ranks first, and "brain-computer interaction" achieves breakthrough
- DSP Demo Programming Example Sharing
- Fudan Micro FM33LC046N Evaluation + External Interrupt
- A brief discussion on the technological innovation and market prospects of Wi-Fi 6E
- Why embedded engineers have misunderstandings about 8-bit MCUs
- Disassemble BYD's smart car key to see what solution it uses
- ST official statement: STM8 and STM32 production capacity description
- Practical Tips
- Are Gallium Arsenide (GaAs) technology solid-state power amplifiers important? Let's discuss its development trend.