Hello. I wired a DC source to a readback cell as below.
Then, I exported the files and programmed the DSP ADAU1701 via NUCLEO-F746ZG board as:
void SIGMA_WRITE_REGISTER_BLOCK(int devAddress, int address, int length, ADI_REG_TYPE *pData) {
ADI_REG_TYPE I2C_buffer[2 + length];
I2C_buffer[0] = (address & 0xFF00) >> 8; // High byte of the address
I2C_buffer[1] = (address & 0x00FF); // Low byte of the address
// Copy the data into the I2C buffer
for (int i = 0; i < length; i++) {
I2C_buffer[2 + i] = pData[i];
}
// Transmit the data via I2C
if (HAL_I2C_Master_Transmit(&hi2c2, DEVICE_ADDR_IC_1, I2C_buffer, 2 + length, HAL_MAX_DELAY) == HAL_OK) {
HAL_GPIO_WritePin(LED_1_GPIO_Port, LED_1_Pin, GPIO_PIN_SET);
} else {
HAL_GPIO_WritePin(LED_1_GPIO_Port, LED_1_Pin, GPIO_PIN_RESET);
}
}
There is no problem by programming the data via MCU. The problem is when I try to read the data back to the MCU via I2C.
I try to read as:
void SIGMA_READ_REGISTER_BYTES(int address, int length) {
ADI_REG_TYPE write_buffer[4];
write_buffer[0]=(0x0000 & 0xFF00) >> 8;
write_buffer[1]=(0x0000 & 0x00FF);
write_buffer[2]=0x00;
write_buffer[3]=0x22;
ADI_REG_TYPE read_buffer[3];
HAL_StatusTypeDef transmitStatus, receiveStatus;
transmitStatus = HAL_I2C_Master_Transmit(&hi2c2, 0x68, write_buffer, 4, HAL_MAX_DELAY);
HAL_Delay(100);
receiveStatus = HAL_I2C_Master_Receive(&hi2c2, 0x69, read_buffer, 3, HAL_MAX_DELAY);
HAL_Delay(100);
if (receiveStatus == HAL_OK) {
HAL_GPIO_WritePin(LED_2_GPIO_Port, LED_2_Pin, GPIO_PIN_SET);
} else {
Error_Handler();
}
}
I exactly write the data outputted in the sigma studio. But the slave doesnt recognizce the device.
Below is where I call read/write functions:
void default_download_IC_1() {
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_IC_1, REG_COREREGISTER_IC_1_ADDR, REG_COREREGISTER_IC_1_BYTE, R0_COREREGISTER_IC_1_Default );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_IC_1, PROGRAM_ADDR_IC_1, PROGRAM_SIZE_IC_1, Program_Data_IC_1 );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_IC_1, PARAM_ADDR_IC_1, PARAM_SIZE_IC_1, Param_Data_IC_1 );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_IC_1, REG_COREREGISTER_IC_1_ADDR , R3_HWCONFIGURATION_IC_1_SIZE, R3_HWCONFIGURATION_IC_1_Default );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_IC_1, REG_COREREGISTER_IC_1_ADDR, REG_COREREGISTER_IC_1_BYTE, R4_COREREGISTER_IC_1_Default );
ADI_REG_TYPE MODE_0_0[4] = {0x00, 0x80, 0x00, 0x00};
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_IC_1, 0x0000, 4, MODE_0_0);
SIGMA_READ_REGISTER_BYTES(0x81A, 4);
}