您好!
如何 从微控制器的 DAC0和 DAC1生成 I 相和 Q 相(正弦和余弦)数据,且 峰峰值电压必须为0.9V?
在哪里可以找到生成 I - PHASE 和 Q - PHASE 数据的示例代码?
此致、
Mounika
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好!
如何 从微控制器的 DAC0和 DAC1生成 I 相和 Q 相(正弦和余弦)数据,且 峰峰值电压必须为0.9V?
在哪里可以找到生成 I - PHASE 和 Q - PHASE 数据的示例代码?
此致、
Mounika
尊敬的 Mounika:
我们没有创建正弦波的示例代码,但我会给你一些建议开始。
TRM 链路 -我强烈建议查看 TRM 的 DAC12部分。
DAC 代码示例- 设置 DAC0、设置 DAC1
此致、
卢克
下面是一个我粘贴到我的项目中的函数,当我需要静态/不经常生成一个 sin ()表。 它使用浮点 sin (),所以你不想太频繁地执行它。 也许您可以将其改编为有用的内容。
#include <math.h> // sin(), M_PI
#define OSR 100000UL // Output rate 100ksps
#define SIN_HZ (1000L) // sin() frequency
#define DACTOP (1L << 12) // 12-bit DAC
#define DACMID (DACTOP/2-1) // Amplitude is centered at half-range
#define NPTS (OSR/SIN_HZ) // Points in a full cycle
int16_t wave[NPTS+1]; // full-wave points
uint16_t wavei;
void
init_data(void)
{
uint16_t i;
for (i = 0 ; i < NPTS+1 ; ++i)
{
wave[i] = DACMID * sin(i*2*M_PI/(OSR/SIN_HZ));
}
wavei = 0;
return;
} // end init_data()