Post Go back to editing

fail to read CHIPID ?

Category: Hardware
Product Number: AD5940 on CN0565 Board, AD5940

Hi, Dear Sir, I just begin to touch AD5940 on the CN0565 Board, power connecting lik this : 

wish to read the CHIPID with spi2 using the code below: 

void AD5940_Initialize(void)
{
int i;
/* Write following registers with its data sequentially whenever there is a reset happened. */
//UART_Printf("AD5940_Initialize\n");
const struct
{
uint16_t reg_addr;
uint32_t reg_data;
}RegTable[]=
{
{0x0908, 0x02c9}, /* 1. Stop watchdog timer */
{0x0c08, 0x206C},
{0x21F0, 0x0010}, /* 2. AFE REPEAT ADC Conversions */
#ifndef CHIPSEL_M355
/* This is AD5940 */
{0x0410, 0x02c9}, /* 3. AFECON Clock Gate Enable */
{0x0A28, 0x0009},
#else
/* This is ADuCM355 */
{0x0410, 0x001a},
{0x0A28, 0x0008},
#endif
{0x238c, 0x0104}, /* 4.Set ADC Chop functions */
{0x0A24, 0x00000008|1 << 0}, /* 5. ALLON External Interrupt Configuration 1 */
{0x0a04, 0x4859}, /* 6. REG_ALLON_PWRKEY */
{0x0a04, 0xF27B}, /* 7 ?? */
{0x0a00, 0x8009}, /* 8.REG_ALLON_PWRMOD, Enable RAM retain function and RAM Retention function */
{0x22F0, 0x0000}, /* 9. AFE Power Mode Configuration */
//
{0x2230, 0xDE87A5AF},
{0x2250, 0x103F},
{0x22B0, 0x203C},
{0x2230, 0xDE87A5A0},
};
//initialize global variables
SeqGenDB.SeqLen = 0;
SeqGenDB.RegCount = 0;
SeqGenDB.LastError = AD5940ERR_OK;
SeqGenDB.EngineStart = bFALSE;
//UART_Printf("init5940_global vars\n");
#ifndef CHIPSEL_M355
AD5940_CsSet(); /* Pull high CS in case it's low */
delay_us(10);
#endif
for(i=0; i<sizeof(RegTable)/sizeof(RegTable[0]); i++)
{
AD5940_WriteReg(RegTable[i].reg_addr, RegTable[i].reg_data);
if (i = AD5940_ReadReg(REG_AFECON_CHIPID))
UART_Printf("REG_AFECON_CHIPID: %x\n",i);
if(i == 0x5501)
bIsS2silicon = bTRUE;
else if(i == 0x5502) /* S3 chip-id is 0x5502. The is no difference with S2. */
bIsS2silicon = bTRUE;
else if (i == 0x5500)
bIsS2silicon = bFALSE;

I had tried many times , only can get a wrong result like the below , I am confused, wish to get the help !!!

Best wishes !  

zimin 

Thread Notes

Parents Reply Children
No Data