Hello,
I've a problem with reading registers, for example ID-Register. I always get 0x00. I can send the correct SPI (MOSI) commands to read the ID register, but MISO doesn't move. I've tried a lot of things the last weeks, but nothing seems to work. I'm really desperated and I hope someone can help me to fix the problem.
I use the ADS1298 Evaluation Module and the PSoC 6 BLE Pioneer Kit.
My SPI Settings: SCLK = 160 kHz, MSB first, CHPA = 1, CPOL = 0
My pin connections:
My SPI communication:
My code-functions:
/* This function sends a command */
void send_command(uint8_t cmd)
{
Cy_GPIO_Clr(AFE_CS_PORT, AFE_CS_NUM); // CS LOW
CyDelay(1);
AFE_SPIM_Write(cmd);
CyDelay(2);
Cy_GPIO_Set(AFE_CS_PORT, AFE_CS_NUM); // CS HIGH
}
/* This function reads out register value */
int read_byte(uint8_t reg_addr)
{
Cy_GPIO_Clr(AFE_CS_PORT, AFE_CS_NUM); // CS LOW
CyDelay(1);
AFE_SPIM_Write(0x20|reg_addr); // First Byte RREG, OPCODE 1;
AFE_SPIM_Write(0x00); // Second Byte RREG, OPCODE 2 --> number of registers to be read = 1
AFE_SPIM_Write(0x00);
out1 = AFE_SPIM_Read();
CyDelay(5);
Cy_GPIO_Set(AFE_CS_PORT, AFE_CS_NUM); // CS HIGH
return(out1);
}
My main-code:
/* Initialize SPI communication */
AFE_SPIM_Start();
__enable_irq(); /* Enable global interrupts. */
/*Reset Chip*/
Cy_GPIO_Set(AFE_RESET_PORT, AFE_RESET_NUM);
CyDelay(1000);
Cy_GPIO_Clr(AFE_RESET_PORT, AFE_RESET_NUM);
CyDelay(1000);
Cy_GPIO_Set(AFE_RESET_PORT, AFE_RESET_NUM);
CyDelay(1000);
/*Reset Communication */
Cy_GPIO_Clr(AFE_CS_PORT, AFE_CS_NUM); // CS LOW
CyDelay(1000);
Cy_GPIO_Set(AFE_CS_PORT, AFE_CS_NUM); // CS HIGH
/* Wait longer for TI chip to start */
CyDelay(500);
/* // Device Wakes Up in RDATAC Mode, so Send SDATAC Command so Registers can be read/ written.*/
send_command(SDATAC);
CyDelay(10);
send_command(STOP);
CyDelay(10);
/* Read register */
read_byte(ID);
CyDelay(10);