已回答假定已回答

AD2S1210用SPI读写,SPI该如何配置?

Danni 在 2018-3-25 詢問的問題
最後回覆由nandin於2018-3-27提供

为了用SPI向AD2S1210寄存器写入数据,我将官网例程改成如下:

 

void WriteToAD2S1210(unsigned char address, unsigned char data)

{

  unsigned char buf;

 

  //write control register address

  buf = address;

 

  SET_WR();

  delay(1);

  CLR_WR();

  delay(1);

 

  SpiaRegs.SPITXBUF = buf<<8;

 

  SET_WR();                //利用WR输入的上升沿予以锁存

  delay(1);

  //write control register address

 

  //write control register data

  buf = data;

 

  SET_WR();

  delay(1);

  CLR_WR();

  delay(1);

 

  SpiaRegs.SPITXBUF = buf<<8;

 

  SET_WR();                //利用WR输入的上升沿予以锁存

  delay(1);

  //write control register data

}

 

其中SPI配置为

 

void spi_init()

{

  SpiaRegs.SPICCR.all =0x0007;             // Reset on, SPI上升沿移出数据, 8-bit char bits

  SpiaRegs.SPICTL.all =0x0006;         // Enable master mode, normal phase,

                                                       // enable talk, and SPI int disabled.

  SpiaRegs.SPIBRR =0x0004;

  SpiaRegs.SPICCR.all =0x0087;         // Relinquish SPI from Reset

  SpiaRegs.SPIPRI.bit.FREE = 1;                // Set so breakpoints don't disturb xmission

}

 

想要改变激励频率 但是一直无法正确写入。

結果