📄 9851.c
字号:
#include <mega16.h>
#include <delay.h>
//------------端口操作宏定义------------------//
#define W_CLK PORTD.0
#define FQ_UD PORTD.1
#define RSET PORTD.2
#define WDATA PORTC
unsigned long f_freq;
unsigned int p_phase;
void updatedds()
{
FQ_UD=0;
W_CLK=0;
WDATA=p_phase<<3;
WDATA|=0x01;
W_CLK=1;
W_CLK=0;
WDATA=(f_freq>>24)&0xff;
W_CLK=1;
W_CLK=0;
WDATA=(f_freq>>16)&0xff;
W_CLK=1;
W_CLK=0;
WDATA=(f_freq>>8)&0xff;
W_CLK=1;
W_CLK=0;
WDATA=f_freq&0xff;
W_CLK=1;
FQ_UD=1;
W_CLK=0;
}
void sendfreq(unsigned long freq)
{
FQ_UD=0;
f_freq=freq*29.826162;
updatedds();
FQ_UD=1;
FQ_UD=0;
}
void sendphase(unsigned int phase)
{
FQ_UD=0;
p_phase=phase;
updatedds();
FQ_UD=1;
FQ_UD=0;
}
void main()
{
DDRC=0xff;
DDRD=0xff;
while(1)
{
sendfreq(1000);
sendphase(1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -