AT89C2051+AD7545 sine signal generator

Publisher:532829319hmkLatest update time:2016-08-08 Source: eefocusKeywords:AT89C2051  AD7545 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
;********************************************************************;

;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

Keywords:AT89C2051  AD7545 Reference address:AT89C2051+AD7545 sine signal generator

Previous article:PC2004 LCM Driver
Next article:SSD1963 Example Program

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号