专家好,最近在用PIC18F与AD2S210控制三相无刷电机,但是在需要对激励频率进行更新时,却无法更新,并且LOT和DOS两个地方一直为低,用示波器观察波形时,
单片机的SDO输出正常,具体硬件配置是:单片机的SDO与AD2S1210的SDI连接,单片机的SDI与AD2S1210的SDO连接,CS一直为低,SCLK引脚与单片机直连,软件基本配置如下:
RESET = 0;
SAMPLE = 1;
__delay_us(20);
RESET = 1;
__delay_us(10);
SAMPLE = 0;
__delay_us(10);
SAMPLE = 1;
SSPCONbits.SSPEN = 1;
CS = 0; //AD2S1210片选
SOE = 0; //AD2S1210串行输出使能
FAULT_Indic = 1; //错误标识
RES0 = 0; //RES0=0 12位分辨率
RES1 = 1; //RES1=1
configureAD2S1210(setMode);
NOP();
AD2S1210_WRITE(CONTROL , 0x7A);
NOP();
AD2S1210_WRITE(EXFREQUENCY , 0x50);
NOP();
AD2S1210_WRITE(LOSTHRES , 0x01);
NOP();
AD2S1210_WRITE(DOSORTHRES , 0x7F);
NOP();
AD2S1210_WRITE(DOSMISTHRES , 0x0D);
NOP();
AD2S1210_WRITE(DOSRSTMXTHRES , 0x01);
NOP();
AD2S1210_WRITE(DOSRSTMITHRES , 0x7E);
NOP();
AD2S1210_WRITE(LOTHITHRES , 0x7F);
NOP();
AD2S1210_WRITE(LOTLOTHRES , 0x7F);
NOP();
void AD2S1210_WRITE(unsigned char address , unsigned char data)
{
unsigned char Add;
unsigned char Parameter;
Add = address;
Parameter = data;
WR = 0;
AD2S1210_SPI(Add);
NOP();
WR = 1;
NOP();
WR = 0;
AD2S1210_SPI(Parameter);
NOP();
WR = 1;
NOP();
}