#include "LPC17xx.h" /* LPC17xx外设寄存器 */
volatile uint16_t GusSinTable[45] = /* 正弦表 */
{
0, 57, 1113, 166, 217, 263, 304,339, 348,
389, 403, 409, 407,397,379, 354, 322, 284,
240, 192, 140, 85, 28, -29, -86, -140, -193,
-241, -285, -323 , -355 , -380 ,-398 , -408 , -410 ,-404 ,
-390 , -369 , -340 , -305, -264, -217,-167,-113, -57
};
void myDelay (uint32_t ulTime)
{
uint32_t i;
i = 0;
while (ulTime--) {
for (i = 0; i < 5000; i++);
}
}
int main (void)
{
uint32_t i;
SystemInit(); /* 系统初始化,切勿删除 */
LPC_PINCON->PINSEL1 |= (0x02 << 20);
while (1) {
for (i = 0; i < 45; i++){
LPC_DAC->DACR = (GusSinTable[i] << 6); /* 输出正弦波 */
}
}
}
为啥这组参数不能够输出正弦波形呢?负数不可以么? |