Post Go back to editing

SPI with another MCU ( nRF52833)


I'm trying to communicate with ad5940 using nRF52833 as the master.

So I'm reconstructing the code by referring to the SPI example of ad5940, and I'm looking for the initialize function first.

These are the initialize functions found in ad5940_SPI example.

After uploading this code, I check the SPI communication data value through Logic analyze, it looks like the following picture.

The first question  is that the codes ad5940 sends to initialize in the data sheet are different from the codes I observe at analyzer. 

The following pictures are the codes I reconstructed in nRF52833 and the analyzer values.







 The analyzer allows me to see that the data value is properly entered, but the address value is strange.

So I'm curious. Why the address value is output strangely even though the same function is used.



best regards.

  • Hi,

    Please follow instructions at this link  for porting to another MCU. You should not make any modifications to AD5940.c file. Can you read back 0x4144 from ADIID register to confirm the SPI comms is good? 

  • Actully, ad5940.c file was not modified.
    However, by referring to the function in ad5940.c file, it was added to main.c of nRF52833 to fit nRF. Are you saying that this method is wrong?

    And I'm sorry. I thought about how to communicate with SPI through the link you advised, but I don't understand it well. Do you have any more detailed examples?

    + And I don't know how to read back the value of ADIID.

  • ----another MCU coding

    ---AD5940 Ramp example

    As you advised, I'm combining codes with another MCU, and this error is coming out.

    In order to find the cause of the error, I have unnoticed the part that defined CHIPSEL_5940 in the AD5940 code,

    and I was able to confirm that it is a duplicate declaration.

    So I think another MCU code should declare CHIPSEL_5940 like AD5940 code. 

    However, I could not find the part that declared CHIPSEL_5940 in AD5940 code.

    Can I get some help?

    Thank you for your help.

  • Hi,

         Read ADIID as below: (refer to ad5940lib/ad5940.c at master · analogdevicesinc/ad5940lib · GitHub)



    * @brief Read ADIID register, the value for current version is @ref AD5940_ADIID
    * @return return none.
    uint32_t AD5940_GetADIID(void)
    return AD5940_ReadReg(REG_AFECON_ADIID);

    Refer to ad5940lib/ad5940.h at master · analogdevicesinc/ad5940lib · GitHub, (AD5940.h )

    where CHIPSEL_594X is defined and commented.

    //#define CHIPSEL_594X /**< AD5940 or AD5941 */  

  • Wow, that was a very simple problem.

    Thanks to your comments, it was solved easily!

    Can I ask you one last question?

    I am currently measuring current through 3electrode, and I thought that there would be a limit if there was more than a certain current (about 1mA).
    So we're going to do high current mode. Is this the right idea?

    If I'm right,

    When I looked up the data sheet about High Current mode, it comes out like the following picture.


    Then do I have to fix this part?

    best regards.

  • Hi,

    #define BITM_AFE_LPTIACON0_IBOOST 0x00000018 /* Current Boost Control */

    already is in high current mode. (LPTIACON0[4:3] =11).

    For changing current boost control, only change BITM_AFE_LPTIACON0_IBOOST.

    Don't change bit position (BITP_AFE_LPTIACON0_IBOOST).

  • Thanks for your help.

    Thanks to your kind explanation, I understood well.

    Because the shape shown by CA was limited to about 1mA of current, i didn't know it was already in high current mode.

    Then how can i measure high current than 1mA?

  • Hi,

    It should be possible to measure upto 3mA with the current settings.

  • I'm sorry for the late reply.
    After reading your reply, I studied the datasheet hard and conducted an experiment to understand it.

    As your answer, the current limit was 3mA.
    However, it is only visible under RTIA=200R conditions.

    If Rtia is higher than 200 R, the current cannot reach 3 mA. It even shows a significant decrease in current value when 1mA is exceeded.

    The following figure shows the test conditions.

    -------------------------------------Rtia 200R

    I thought that the current must be 1.2mA by Ohm's law(1.2V/1k =1.2mA).

    So I adjusted the RLoad value to be as similar as 1.2mA as possible.

    Due to the lack of understanding of Rtia and Rload in this process, it has been found through several attempts.

    Can you tell me how to adjust Rtia and Rload to get a current value similar to Ohm's law when there is a specified resistance value?

    -------------------------------------Rtia 1K

    In Rtia 1k, the current value of the negative sign was identified when the sensorBias value was increased. I also don't know how to analyze this data because of the lack of understanding of Rtia and Rload.

    I'm sorry for the many questions. And nevertheless, thank you for always leaving a kind reply!

    Best regards

  • Hi,

         To calculate the required gain resistor, use the following equation:

    IMAX = 0.9V/RTIA,

    where IMAX is the expected full-scale input current. RTIA is the required gain resistor.

    Once RTIA is selected, Rload may be chosen as below:

    The RTIA is combination of RLOAD and a fixed series 110 Ω.

    If RLOAD ≤ 100 Ω,

    RTIA = (100 Ω − RLOAD) + TIAGAIN.

    If RLOAD > 100 Ω,

    RTIA = TIAGAIN − (RLOAD − 100 Ω).           //(TIAGAIN =  LPTIACONx[9:5])