我可以对8750进行编程,但同一程序不起作用。 我使用了EVM和另一个原型板。
包含"mbed.h"
#include "SWSPI.h"
//地址字节
#define ADDR_NOP 0x00 //无操作(NOP)
#define ADDR_DATA 0x01 //写入DAC数据寄存器
#define ADDR_READ 0x02 //注册读取
#define ADDR_CTRL 0x55 //写入控制寄存器
#define ADDR_reset 0x56 //写入重置寄存器
#define ADDR_config 0x57 //写入配置寄存器
#define ADDR_Gain 0x58 //写入DAC增益校准寄存器
#define ADDR_ZERO 0x59 //写入DAC校零寄存器
#define ADDR_WDT 0x95 //监视器计时器重置
#define CTRL_SET 7 //控制寄存器设置0-24mA
DigitalOut GPO(D0);
数字输出LED (LED_RED);
SWSPI DAC (D11,D12,D13);// mosi,miso,sclk,sel
数字输出插销(D10);
void sendtodac (int,int);
void sendtodac (int address,int cmd0){
dac.frequency(5万);
int cmd[2];
dac.write (address);//地址字节
cmd[0]= cmd0和0xFF;
cmd[1]=(cmd0 >> 8);
dac.write (cmd[1]);//MSB
dac.write (cmd[0]);//LSB
闩锁= 1;
闩锁= 0;
}
void initdac (void);
void initdac (void){
sendtodac (ADDR_RESET,0x01);
sendtodac (ADDR_CTRL,0x1007);
}
Int dacin = 0;
INT MAIN ()
{
DAC.FORMAT (8,3);
dac.frequency(5万);
initdac();
Int dacin = 0;
//sendtodac (ADDR_DATA,5.4613万);
同时(true){
GPO =!GPO;//切换引脚
LED =!LED;//切换LED
等待(1.0f);
sendtodac (ADDR_DATA,dacin);
// sendtodac (ADDR_data,5.4613万);
dacin +=5000;
如果(dacin > 6.5万) dacin = 0;
}
}