⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dacsine.c

📁 最新版IAR FOR ARM(EWARM)5.11中的代码例子
💻 C
字号:
/********************************************************************

 Author        : ADI - Apps            www.analog.com/MicroConverter

 Date          : May. 2004

 File          : DACsine.c

 Hardware      : Applicable to ADuC7020/ADuC7024/ADuC7026
                 Currently targetting ADuC7024.

 Description   : DAC outputs a sine wave on pin 10 (DAC1).
		 DAC is updated with core clock frequency 45MHz.

                 Note set the baud rate for the Rom Monitor to 9600baud.     	

********************************************************************/

#include <Analogdevices/ioaduc7024.h>

int main (void)  {
	// 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;

	// DAC configuration
	DAC1CON = 0x13;			// range AVdd/AGND
					// DAC1 is updated with falling edge of core clock
	DAC1DAT = 0x08000000;		// start from midscale

	while(1){
	DAC1DAT = (TableS[i] << 16);
	i++;
	i &= 0x03f;         	
	}

}

// IMPORTANT - The amount of stack spaces allocated for the IRQ stack is
//             defined by __ICFEDIT_size_irqstack__ in the linker script file. 
//             If you add additional function calls or additional local 
//             variables then you should verify that __ICFEDIT_size_irqstack__ 
//             is still sufficiently large to prevent overflow of the stack and 
//             corruption of data
//             All default exception handlers (except reset) are defined as weak 
//             symbol definitions.
//             If a handler is defined by the application it will take precedence.
__irq __arm void IRQ_Handler(void)                      //      IRQ Handler
{
   while (1);  
}

// IMPORTANT - The amount of stack spaces allocated for the FIQ stack is
//             defined by __ICFEDIT_size_fiqstack__ in the linker script file. 
//             If you add additional function calls or additional local 
//             variables then you should verify that __ICFEDIT_size_fiqstack__ 
//             is still sufficiently large to prevent overflow of the stack and 
//             corruption of data
//             All default exception handlers (except reset) are defined as weak 
//             symbol definitions.
//             If a handler is defined by the application it will take precedence.
__fiq __arm void FIQ_Handler(void)                 //      fiq Handler
{
   // Replace this while (1) code with a proper handler for the fiq source
   while (1);  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -