ADC0832 realizes a sine wave with an output frequency of 50HZ

Publisher:omicron25Latest update time:2016-09-22 Source: eefocusKeywords:ADC0832 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
//-----------------------------
Function: ADC0832 realizes the output frequency of 50HZ sine wave
1, P0 port sends data,
 2, P2.0 port is used as chip select signal
    P21 is DAC start signal;

#include
#define uint unsigned int 
#define uchar unsigned char
uchar code table[]={ //sine wave data       
       128,130,132,135,137,139,141,144,146,148,150,152,155,157,159,161
       163,165,168,170,172,174,176,178,180,182,184,186,188,190,192,194
       196,198,200,201,203,205,207,209,210,212,214,215,217,219,220,222
       223,225,226,227,229,230,232,233,234,235,237,238,239,240,24
       1,242 243,244,245,246,247,247,248,249,250,250,251,252,252,253,253,254
       254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255
       255,255,255,254,254,254,253,253,252,252,251,250,250,249,24
       8,247 247,246,245,244,243,242,241,240,239,238,237,235,234,233,232,230
       229,227,226,225,223,222,220,219,217,215,214,212,210,209,207,205
       203,201,200,198,196,194,192,190,188,186,184,182,180,178,17
       6,174 172,170,168,165,163,161,159,157,155,152,150,148,146,144,141,139
       137,135,132,130,128,126,124,121,119,117,115,112,110,108,106,104
       101,99,97,95,93,91,88,86,84,82,80,78,76,74,72,70,68,66,64 ,
       62,60,58 56,55,53,51,49,47,46,44,42,41,39,37,36,34,33,31,30,29,27,26,24,23,22
       21,19,18,17,16,15,14,13,12,11,10,9,9,8,7,6,6,5,4,4,3,3,2,2,2,1,1
       1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,4,4,5,6,6,7,8,9,9
       ,10,11,12 13,14,15,16,17,18,19,21,22,23,24,26,27,29,30,31,33,34,36,37,39,41,42
       44,46,47,49,51,53,55,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86
       88,91,93,95,97,99,101,104,106,108,110,112,115,117,119
  ,121,124,126,128 };
sbit cs=P2^0;
sbit dac=P2^1;
uchar num1,num2,num3,flag;
uchar aa,bb;
void delay();
void ad0832();
void main()
{
 TMOD=0x01;
 TH0=(65536-20000)/256;
    TL0=(65536-20000)%256;
    ET0=1;
 EA=1;
 TR0=1;
 
   while(1)
    {   
  if(flag==1)
    { i++;
           if(table[i]=='\0')
             i=0;
    ad0832();
   flag=0;        
  }
      
 }
    
 
}
//===================
void delay(uint z)
{
   uint x;
   uchar y;
 for(x=0;x  for(y=0;y<100;y++);
}
//-------------------------
void ad0809()
{
  cs=0;
  dac=1;
  delay(1);
  P0=table[i];
  dac=0;
  delay(10);
        
 
}
//=======================
void timer0()  interrupt 1
{
 TH0=(65536-20000)/256;
    TL0=(65536-20000)%256;
      
  flag=1; 
  
}
Keywords:ADC0832 Reference address:ADC0832 realizes a sine wave with an output frequency of 50HZ

Previous article:8-bit digital tube dynamically displays time, adjustable, the adjusted number flashes
Next article:LCD1602 clock displays time and date with alarm and can be adjusted cyclically

Recommended ReadingLatest update time:2024-11-17 08:45

51 MCU: Use ADC0832 to do analog-to-digital conversion and measure voltage
Question Requirements Using 51 single chip microcomputer and an ADC0832 analog-to-digital converter, design a circuit that can measure voltage in real time. The measurement voltage range is 0-5V (allowable error), and the measured voltage is required to be displayed in real time with a digital tube, accurate to two de
[Microcontroller]
51 MCU: Use ADC0832 to do analog-to-digital conversion and measure voltage
Use the microcontroller timer T0 to generate a 50HZ square wave
Solution: The period of a 50HZ square wave is 20ms. A timer can be used to generate a 10ms timing. By changing the level of P1.0 every 10ms, a 50HZ square wave can be obtained. At this time, timer T0 should be operated in mode 1. The initial value of T0 when operating in mode 1 is calculated according to the following
[Microcontroller]
How to change the 30Hz to 50Hz on the inverter?
First, you need to understand how to view and modify the function codes of various inverters; For inverters from different manufacturers, you can only ask the manufacturer for the user manual of the corresponding model to set the parameters; because their function codes, names, setting ranges, and factory defau
[Embedded]
How to change the 30Hz to 50Hz on the inverter?
Simple digital voltmeter + ADC0832 + serial SPI mode to achieve 1-way data conversion
1 Objects and models (1) Why are the DO and DI pins connected to one pin? Since ADC0832 does not use the DO and DI ports at the same time during communication, and the interface between the DO and DI ports and the microcontroller is bidirectional, a wire can be used to connect the DO and DI ports
[Microcontroller]
Simple digital voltmeter + ADC0832 + serial SPI mode to achieve 1-way data conversion
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号