Post Go back to editing

AN9541-BATImpedance integration with other controllers (no ADICUP3029 CPU)

Thread Summary

The user encountered issues integrating AD5940/AD5941 BAT Impedance application code with a Linux-based system, including missing jumpers (JP7, JP8, JP9) and incomplete SDK documentation. The final solution involved installing JP7 and JP9, rewriting SPI drivers to handle 16-bit and 32-bit register access correctly, and ensuring proper sequencer and interrupt configurations. The AD5940/AD5941 datasheet and SDK were criticized for lacking clarity and completeness, particularly regarding register definitions and silicon revisions.
AI Generated Content
Category: Software
Product Number: EVAL-AD5941BATZ, AD5941, AD5941, AD5941
Software Version: 1

Hi Akila, and others in you team.
I am trying to integrate the BAT Impedance application code examples with my Linux based system (no ADICUP3029 CPU)
I

Edit Notes

After further investigation progress has been made see latter posts
[edited by: CAMTEK at 11:03 AM (GMT -5) on 28 Nov 2025]
Parents
  • Further Notes_9

    Below is a picture of the EVAL-AD5941BATZ BOARD as shipped. Are all required jumpers installed correctly for this APP?



    1. As can be seen JP7 is shipped linked in A position --> Connects GPIO0 to Adruino header D2 (P6/3) 
    2. No headers/links are provided for JP8, JP9, JP1 or JP2 
    3. Links are in for P1 & P8 and no headers provided for P4 

    4. Please explain how the code functions below are meant to work without links for JP8 and JP9 installed. Since these (and other) functions below are called in the BATImpedence.c file in the ADI SDK which uses Arduino Pins D3/D4 linking them to GPIO1/GPIO2?

          PreCharge(PRECHARGE_BAT);
          PreCharge(PRECHARGE_AMP);

    5. Also is there some conflict (multiple use) in using GPIO2 (same as above) to also control the ADG636YRUZ analog Switch in the BATImpedance.c code function ....AppBATCtrl() ?
    If JP9 is installed in Position A, then GPIO2 and Adruino Pin D4 (P6/5) are in conflict and may be driving each other?

    6. 

     



  • Kindly refer to CN0510 board schematic for jumper and header connection details: EVAL-AD5941BATZ Design & Integration Files

  • Thanks for your response Akila,

    I don’t mind if additional parts or jumpers are required, provided this is clearly stated in the documentation. What I do expect, however, is that the boards supplied should work with the example code as delivered. In this case, the board simply cannot function as expected without those jumpers, and therefore they should have been included.

    Your own image illustrates that the jumpers are not installed, even when using the ADuCM3029 CPU as shown. Could you please explain how the ADI example code was able to run correctly without those jumpers in place?

    Since you acknowledge the documentation is confusing, it would be in ADI’s interest to update it—especially given how long this issue has persisted. My concern was never with the evaluation examples themselves or the ADI code, but rather with obtaining timely, expert guidance on porting matters. The lack of clarity around the jumpers caused unnecessary confusion, and some straightforward advice could have saved me considerable time.

    I must admit I lost quite a bit of time because of those unexpected jumpers—Murphy’s law at work. That said, everything is now sorted on my end. Smiley

    Regards,


    Collin.





  • JP8 and JP9 are connected to gpio1 and gpio2 which are not even used in battery impedance code. gpio2 is directly connected to switch mux for setting its address, which in this code is set to "0x11" by default. I don't understand how it blocks functioning of example code on ADuCM3029.

  • Hi Akila,

    Thanks for your reply,

    You said "JP8 and JP9 are connected to gpio1 and gpio2 from D3/D4 which are not even used in battery impedance code. gpio2 is directly connected to switch mux for setting its address, which in this code is set to "0x11" by default"

    If they are not even used in the Batt-Impedance code, then why does the code set them to "0x11" as you stated above?

    "I don't understand how it blocks functioning of example code on ADuCM3029." ......

    Ah the process of self discovery will be enlightening, let me know when you have figured it out?

    Best Regards.
    Collin.

  • HI Camtek,

     There is nothing to figure out. The default board with ADuCM3029 works proper as with all other users.

    If you still didn't notice, GPIO2 is pulled up on board, hence switch mux sees "0x11" on address lines.

    Stating again, GPIO1 and GPIO2 (from D3/D4) are not used anywhere in the code. There is no need for JP8 and JP9, hence they are DNI.

  • Hi Akila,

    Thank you for your confirmation,

    As you have clearly stated the following:

    1 ."GPIO2 is pulled up on board, hence switch mux sees "0x11" on address lines" 

    2. "Stating again, GPIO1 and GPIO2 are not used anywhere in the code."

    3. "There is no need for JP8 and JP9, hence they are DNI."

    In response, I state again "the board simply cannot function as expected without those jumpers, and therefore they should have been included"

    Why?

    1. With the ADG636 mux switch's address lines only pulled "high" (and not used as you claim) that means the AD5940 Analog input channels (via the input amplifier) can only see the REF_P and REF_N inputs and can therefore only sense the RCAL voltage .... hence your Test Sweeps are showing "FAKE/FALSE" impedance data during the RUN phase. So in fact you are just measuring the impedance of RCAL ... not the BATTERY (DUT) ... is that the intended function?

    2. Regarding your item 2 quote above, GPIO1 and GPIO2 are clearly referenced in your SDK code using the Arduino connections "d3/d4"
    and called in BATImpeance.c functions ...Arduino_WriteDn() and  PreCharge() which supposedly directly control both GPIO1 and GPIO2?

    3. Regarding your item 3 above, I think there is clearly a need if you want the board to function as intended, the proof is in the pudding as I have installed these jumpers and control them with my own code that works as intended ?

    My posted questions were a result of a genuine need to get some expert answer's and help in a timely manner, the questions may have been silly and easily answered by an expert such as yourself, but for a novice like me maybe not.

    Hope you see my point. Thumbsup

    Best Regards,
    Collin.

  • 1) First of all, GPIO2 is directly connected from AD5941 to AD0/AD1 of address pins. GPIO2 is an interrupt coming from AD5941,and is definitely not controlled by D3. Why do you need JP8/9 to control this gpio2? (Here, if you want to say that gpio2 is indeed part of the code, refer to point 3).

    Either you can't control your words or it is weird that you conclude that all users are happy showing fake data as the output they get. 

    2) D3 and D4 are used to control ADG1609BCPZ directly from Arduino side. It has nothing to do with JP8/JP9 or gpios.

    3) Clearly, in the above two cases, you wanted to make a desperate complaint even if the jumpers are not relevant to the intended test.

    I just hope that you refer to all EZ queries on AD5941/0 or battery impedance measurement for your doubts. That is the purpose of this portal, where Qs need not be repeated.

    I understand there is not much discussion in EZ regarding Linux porting, but that is a dedicated software work which is not an open-source deliverable from ADI and which if needed is to be discussed on mail for your specific application.

  • Hi Akila,

    Thanks for your response, 

    Finally I am getting the kind of responses for my original enquiries and questions even if it took over 2 months. During that time with no ADI help to set things straight from start, I had to pursue my own course of investigations from scratch.  

    Can you detail exactly what part of code in the BATImpedance App actually controls the GPIO2 line, is it in the sequencer?
    Or is this another secret, I have to investigate?
    How is the AD5940 GPIO2 Interrupt line programmed and how and when exactly is the interrupt generated. These are sorts of clarifications I originally sort without any help. I never asked that ADI to port my code, I asked these questions so I could do it myself, but never did receive any responses until now. 

    I never intended to make desperate complaints, I wanted some answers and only now you seem to be providing some, maybe because you've been directed to do so from higher ups, even so you should remember that I first directed these questions "marked to your attention" as per the original posts clearly show. 

    You or a knowledgeable colleague could have easily responded to answer, months ago?

    Even so the original BATImpedance code did not work in my case that's why I had to force control of the mux switch GPIO2 line, and that produced a working result for me, because as you now know that the mux switch needs to be controlled ...unlike your previous response when you definitely denied it!

    "Alas and that's exactly what you denied in your previous post.... 
    Quote: ... "Stating again, GPIO1 and GPIO2 are not used anywhere in the code."... but now you are saying different again.

    So I can only conclude that just now you must have discovered something new as a result of my feedback and queries? .. no thanks needed.

     Further more ... in BATImpedance.c there are several functions that call the D3/D4 lines (GPIO1 & GPIO2) ... in such functions as ... 
    AD5940Err AppBATCtrl(), PreCharge(), Arduino_WriteDn() etc ... so please care to explain... are they dead not needed trash code?

    Finally, there is no need for your outburst's that claim " I wanted to make a desperate complaint", that's not true and a rather poor ADI response after > 2months of waiting! 

    Again I repeat, all these questions and enquires could have been easily answered much sooner by your expertise and saved a lot of unnecessary wasted time...

    Thank you for your response, its been delightful Smiley
    Best Regards,
    Collin




  • Akila,

    Ah, I think i found the code you are talking referring to, is this it?
    But I need more details on exactly how it controls the GPIO2 pin on the AD5940.

    AD5940_WriteReg(REG_AFE_SWMUX, 1<<0);
    REG_AFE_SWMUX is the switch matrix register, not the GPIO register

    Please explain how this is meant to work exactly?

    This maybe the possible reason the code did not work in my Linux Porting and the original reasons I asked these questions but with little or no ADI response.

    IVAN was the only ADI person to provide any helpful response in the past. 

    Regards
    Collin

  • Well, you could have found this earlier had you read the code fully. 

    Since, you have already got your system running, good luck with your progress. Hope you end this conversation.

    ps: Above answer is explained in datasheet below:

  • Akila, Thanks for the response.

    You could have responded on these very questions +2months ago, and saved me time and it does seems you have only just learned all this information now.

    My own code solutions fixed the issues above and controls the GPIO2 line in the same manner, and yes my project has progressed immensely since.  

    Thanks again Akila.Wave
    Collin


Reply
  • Akila, Thanks for the response.

    You could have responded on these very questions +2months ago, and saved me time and it does seems you have only just learned all this information now.

    My own code solutions fixed the issues above and controls the GPIO2 line in the same manner, and yes my project has progressed immensely since.  

    Thanks again Akila.Wave
    Collin


Children
No Data