昨晚DDS产生了波形,怎么写频率字 好像只出现两种频率
一个 380Hz,一个 10Hz? 刚开始好像有2KHz的?
void AD9833_WriteWord(U16 Dat)
{
U8 SFRPAGE_save = SFRPAGE;
SFRPAGE = ACTIVE_PAGE;
NSS = 0; // Activate Slave Select
// first High Byte
SPI0DAT = (U8)((Dat >> 8) & 0x00FF);
while (!SPIF);
SPIF = 0;
// then Low Byte
SPI0DAT = (U8)(Dat & 0x00FF);
while (!SPIF);
SPIF = 0;
NSS = 1; // Deactivate(Stop) Slave Select
Delay_us (1);
SFRPAGE = SFRPAGE_save;
}
void AD9833_Reset(void)
{
AD9833_WriteWord(0x0100);
AD9833_WriteWord(0x2100);
AD9833_WriteWord(0x47FF);
AD9833_WriteWord(0x4000);
AD9833_WriteWord(0x2000);
}
应该调节第三个 AD9833_WriteWord里面的参数就可以改变频率了,但是……
悲催。 |