Interesting note. Wonder if anyone else has experienced this. I can read or write just fine to the EVK, but only one to five addresses at a time. The datasheet says that if csb is kept low, the address counters in the DAC will be incremented automatically. However That is now what I am experiencing. No data seems to be shifted out (or on successive writes) beyond 5-10 successive reads. Going through the provided Evkit code, which runs fine, I realized they do not use multi-word writes or reads. I thought this strange. My goal was to use DMA, but it suffers the same issue. Has anyone else encountered this? Another interesting note is it will not begin a read from register 0x00. Only 0x01 or higher? Trying to read from Reg 0x00 yields no data at all.
Here is are my SPI Settings:
Ful-Duplex Master, NSS Disabled., MOTO FRAME, 16bit data size, MODE: 0 (CPOL=0, CPHA=0), 1Mbps freq (64Mhz I/O clock with 64 prescaler).I dropped in two clock cycle spacing between words, but that made no difference.
startaddr=k+0x8001; // 9102 Reg Addr 0x00, MSB set to Write
HAL_GPIO_WritePin(GPIOI, GPIO_PIN_0, GPIO_PIN_RESET); // csb low. Verified on O'scope.
HAL_SPI_Transmit(&hspi2, (uint8_t *) &startaddr , 1,100 ); // 0x0000+0x8001 (AD9102 Addr 0x1
HAL_SPI_Receive(&hspi2, (uint8_t *) &ReadData, 15, 100); // Array of 96, zero's out first.
HAL_GPIO_WritePin(GPIOI, GPIO_PIN_0, GPIO_PIN_SET); // csb high. Chip Select off.
// I see the clock bursts for all 15 reads, but only some of the data. It seems that after more than 5-10 reads it stops reading.
// If I change startaddr in a loop, I can sequentially read one address at a time just fine as long as I keep the read length below 5.
Picture below shows write address, then first word, (register 0x1) then nothing thereafter. Note: not all words have data. Many are zero. So I'm really looking at points where I know data exists. The second word should have data.
For Comparison sake, CMSIS library implementation of AD910x Class .
A working read defined on the provided EVKIT software using the CMSIS library is as follows: Note single read/writes only.
* @brief Read 16-bit data from AD910x SPI/SRAM register
* @param addr - SPI/SRAM address
* @return reg_data - data returned by AD910x
int16_t AD910x::spi_read( uint16_t addr )
csb = 0;
read_addr = 0x8000+addr; // I notice they also had to set the write bit. That is a must for setting up a read.
spi.write( read_addr );
reg_data = spi.write( 0 ); // Then read from address 0. I assume this keeps MOSI quiet in full duplex mode.
csb = 1;
wait_us( 1 );