📄 dacsineclk.c
字号:
/********************************************************************
Author : ADI - Apps www.analog.com/MicroConverter
Date : Sept. 2005
File : DACsineClk.c
Hardware : Applicable to ADuC702x rev H or I silicon
Currently targetting ADuC7026.
Description : DAC outputs an intermittent Sine Wave on pin 10 (DAC1).
S1.8 must be off
To increase the approximation of a Sine Wave reduce
T1Delay.
********************************************************************/
#include<ADuC7026.h>
void My_IRQ_Function();
// Table is placed in Flash/EE
const static unsigned short TableS[64] = {
0x07FF, 0x08C8, 0x098E, 0x0A51, 0x0B0F, 0x0BC4, 0x0C71, 0x0D12,
0x0DA7, 0x0E2E, 0x0EA5, 0x0F0D, 0x0F63, 0x0FA6, 0x0FD7, 0x0FF5,
0x0FFF, 0x0FF5, 0x0FD7, 0x0FA6, 0x0F63, 0x0F0D, 0x0EA5, 0x0E2E,
0x0DA7, 0x0D12, 0x0C71, 0x0BC4, 0x0B0F, 0x0A51, 0x098E, 0x08C8,
0x07FF, 0x0736, 0x0670, 0x05AD, 0x04EF, 0x043A, 0x038D, 0x02EC,
0x0257, 0x01D0, 0x0159, 0x00F1, 0x009B, 0x0058, 0x0027, 0x0009,
0x0000, 0x0009, 0x0027, 0x0058, 0x009B, 0x00F1, 0x0159, 0x01D0,
0x0257, 0x02EC, 0x038D, 0x043A, 0x04EF, 0x05AD, 0x0670, 0x0736
};
int i = 0;
int main (void) {
unsigned long T1Delay = 0x4000;
IRQEN = 0x08;
IRQ = My_IRQ_Function;
// DAC configuration
DAC1CON = 0x33; // DAC configuration
// range AVdd/AGND and Clocked
DAC1DAT = 0x08000000; // start from midscale
// timer 1 configuration
T1LD = T1Delay;
T1CON = 0xC4; // Enable Timer, Periodic and Core CLK / 16
while(1)
{
}
return (0);
}
void My_IRQ_Function()
{
DAC1DAT = (TableS[i] << 16);
i++;
i &= 0x03f;
T1CLRI = 0x01; // Clearing Timer 1 Interupt
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -