JN5169 ADC Problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

JN5169 ADC Problem

2,051 Views
mferrari1
Contributor III

I have written the following function to configure and enable the JN5169 ADC:

/*****************************************************************************
* NAME: vConfigureADC()
* DESCRIPTION: Calls the necessary functions to bring up the ADC
*****************************************************************************/

void vConfigureADC( void )
{

vAHI_ApConfigure( E_AHI_AP_REGULATOR_ENABLE,
                  E_AHI_AP_INT_DISABLE,
                  E_AHI_AP_SAMPLE_2,
                  E_AHI_AP_CLOCKDIV_500KHZ,
                  E_AHI_AP_INTREF );

vAHI_ProtocolPower(TRUE);

vAHI_ApSetBandGap( E_AHI_AP_BANDGAP_ENABLE );

while( bAHI_APRegulatorEnabled() == FALSE );

// PROBLEM:  bAHI_APRegulatorEnabled() never returns "TRUE"...

vAHI_AdcEnable( E_AHI_ADC_SINGLE_SHOT, E_AHI_AP_INPUT_RANGE_1, E_AHI_ADC_SRC_ADC_1);

}

Because bAHI_APRegulatorEnabled() never returns TRUE, the program gets stuck here.

What am I doing wrong...?  

Is there something else needed in order for bAHI_APRegulatorEnabled() to return TRUE?

Thanks, Matt

Tags (2)
0 Kudos
19 Replies

1,517 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Matt,

Could you please confirm the SDK Version that you are working on? Are you working on JN-SW-4163? Aren't you?

Also, what is the AN that you take as reference?

Regards,

Mario

0 Kudos

1,517 Views
mferrari1
Contributor III

Hi Mario –

Here’s what I’m using:

Beyond Studio for NXP Build 1308

Eclipse IDE for NXP JN51xx C/C++ Developers

Eclipse Version 4v3v1 (Kepler)

JN-SW-4141 BeyondStudio for NXP v1308.exe

JN-SW-4163 IEEE802.15.4 SDK v1416.exe

I started out with JN-AN-1174, but for my application I have entirely rewritten it.

Thanks,

Matt

0 Kudos

1,517 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Matt,

I tested by my side using the JN-AN-1174 and I added after the vInitSystem(); I do not modify anything from the code

PUBLIC void AppColdStart(void)
{
    /* Disable watchdog if enabled by default */
    #ifdef WATCHDOG_ENABLED
    vAHI_WatchdogStop();
    #endif

    vInitSystem();
    vAHI_ApConfigure(E_AHI_AP_REGULATOR_ENABLE,
      E_AHI_AP_INT_DISABLE,
      E_AHI_AP_SAMPLE_2,
      E_AHI_AP_CLOCKDIV_500KHZ,
      E_AHI_AP_INTREF);
    DBG_vPrintf(TRUE, "\nAPP: E_AHI_AP_BANDGAP_ENABLE ");
    vAHI_ApSetBandGap( E_AHI_AP_BANDGAP_ENABLE );
    DBG_vPrintf(TRUE, "\nAPP: bAHI_APRegulatorEnabled Done");

    vStartActiveScan();

    while (1)
    {
        vProcessEventQueues();
     vTransmitDataPacket(&TxData,9,0x0000);
    }
}

pastedImage_1.png

What is the JN5169 module that you have?

Regards,

Mario

0 Kudos

1,517 Views
mferrari1
Contributor III

Hi Mario –

I’m using the JN5169-001-M06-2Z module which seems to be working fine in every way except for this ADC problem.

I stripped everything out of my project except the ADC stuff. The code still crashes when the call is made to:

vAHI_ApSetBandGap( E_AHI_AP_BANDGAP_ENABLE );

I have attached this stripped down project to this email for you.

Could you please do the following:

1) Run this code as-is without rebuilding it first and see if it crashes for you too.

2) Then rebuild the project on your system and then see if it starts working or if it still crashes.

I’m beginning to wonder if perhaps my SDK has been corrupted…

I am very curious to hear what happens when you do the two tests above.

Thanks Mario,

Matt

0 Kudos

1,517 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Matt,

It works by my side without compiling and compiling

pastedImage_1.png

Do you have more modules? Could you please try with the example without modifying?

Did you modify the SDK?

Regards,

Mario

0 Kudos

1,517 Views
mferrari1
Contributor III

Hi Mario –

Thank you for doing this test. If my .bin file runs without error on your hardware, but fails on my hardware, then apparently this is a hardware issue, not a coding or build issue.

I have not modified my SDK. If any modification to the SDK exists, it would be due to corruption, not anything intentional. But this is likely not an SDK issue since my build ran just fine for you.

I have tested on two modules, but I will test on a third brand new assembly just to make sure.

If this problem could be something on my board, then I would like to know:

What external hardware conditions will cause the vAHI_ApSetBandGap( E_AHI_AP_BANDGAP_ENABLE ) call to fail on the JN5169-001-M06-2Z?

I am applying an external signal to each of ADC1 (Module Pin-1) and ADC2 (Module Pin-27). These signals are driven by an Op Amp which is powered from the same 3.3V as the JN5169, so the signal levels are guaranteed to be ok.

Pin-27 can function as either ADC2 or VREF. Is there a VREF issue that is causing the function call to fail? As you can see in my code, I am NEVER selecting an external source for VREF (through vAHI_ApConfigure() ), which the User Guide cautions against. Other than this caution, I see no other requirements related to calling vAHI_ApSetBandGap().

So I guess my question is this: “What external hardware conditions will cause the vAHI_ApSetBandGap() function call to never return?

Since I don’t have access to the source code for this function, I cannot debug this problem, but perhaps you can find out what conditions would cause this function to not return. That might point to what’s causing this issue.

Thanks Mario,

Matt

0 Kudos

1,516 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Matt,

Could you please check the connections and the voltage that you have in the VDD and VSS pins?

Did you test in the third module?

Regards,

Mario

0 Kudos

1,517 Views
mferrari1
Contributor III

Hi Mario –

Please see the attached screenshot.

As expected, the third board behaved exactly the same as the prior two boards.

Once I call vAHI_ApSetBandGap() it never returns.

Just to be sure it just wasn’t a message display problem, I put a “Success” message after the call to the function, then entered a while( 1 ); loop (yes, the Watchdog is disabled).

This problem has remained unresolved for a long time now and is beginning to threaten the release date for this project.

Perhaps you can escalate this issue within NXP?

I have suggested several times to have NXP look at the source code for this function and let us know what will cause the function to not return, but as far as I can tell, that hasn’t happened yet.

Knowing what will cause this function to not return should point us to the source of the problem. Can you please find out about that?

Since this is a Jennic/NXP API, I don’t have access to the source code. It’s an NXP Black Box that I call and never return from.

I don’t know what more I can do. Please advise.

Thanks,

Matt

0 Kudos

1,517 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Matt,

I am in touch with the Validation Team. We are working on your issue, I will get back to you as soon as I have a workaround or feedback.

Regards,

Mario

0 Kudos

1,517 Views
mferrari1
Contributor III

Hi Mario –

I have solved the mystery about the failure of the vAHI_ApSetBandGap() function failure to return.

This function should not be called when using the ADC2 Pin as an ADC input signal.

Whereas all the example code calls this function, whereas the code you sent me calls this function and whereas the function name itself suggests that this function is used to select the Internal Band Gap Reference as the Reference for the ADC, the truth is that this function actually routes the internal reference out to the ADC2 pin so that it can be externally bypassed if so desired.

Calling vAHI_ApSetBandGap() when an external signal is being applied to the ADC2 Input will cause VREF to fail, as VREF will now be shorted to the signal being externally applied to ADC2.

So the correct answer is: “Don’t call vAHI_ApSetBandGap() when ADC2 is being used to measure an Analog Input signal”.

Matt

0 Kudos

1,517 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Matt,

Thank you for share your feedback.

I still waiting for any feedback from the Validation Team.

Please let me know if you have any other question,

Regards,

Mario

0 Kudos

1,517 Views
mferrari1
Contributor III

Thank you Mario. At the moment everything is working fine now, and I have no further questions.

Thank you for your support. If any other questions come up, I will be in touch.

Thanks again,

Matt

1,517 Views
mferrari1
Contributor III

Thank you Mario!

0 Kudos

1,517 Views
mferrari1
Contributor III

Hi Mario –

All the connections to the JN5169-001-M06-2Z module are made on my PCB and are OK.

The supply voltage to the module is a solid and quiet 3.3VDC (Module Pin-17). The Ground connection at Pin-18 is good as well.

I am applying a constant DC voltage of 3mV at ADC2 (Pin-27) and a constant DC voltage of 100mV at ADC1 (Pin-1).

I will be able to test a 3rd module on Monday and will let you know what I find then.

In the meantime, would it be possible for you to ask NXP to look at their code and tell us what conditions will cause the vAHI_ApSetBandGap() function to not return (or crash)?

Everything on the module is running fine, including the SPI Master, Antenna Diversity feature, JTAG Interface, DIOS, IRQs/ISRs and the 802.15.4 Stack. Everything’s working great except this ADC problem with the function vAHI_ApSetBandGap() . I am hopeful that NXP can shed some light on what this function requires to properly return, I’m sure that would point to the problem.

Thanks Mario,

Matt

0 Kudos

1,517 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Matt,

What is the pin that you are using?

Did you turn on the clock wireless transceiver previously? Could you please try without the vAH_ProtocolPower? The API must be called if is necessary.

    /* Set up the analogue peripherals ready to handle the conversions */
    vAHI_ApConfigure(E_AHI_AP_REGULATOR_ENABLE,
                     E_AHI_AP_INT_DISABLE,
                     E_AHI_AP_SAMPLE_2,
                     E_AHI_AP_CLOCKDIV_500KHZ,
                     E_AHI_AP_INTREF);

    vAHI_ApSetBandGap( E_AHI_AP_BANDGAP_ENABLE );
    while (!bAHI_APRegulatorEnabled()); ‍‍‍‍‍‍‍‍

Please let me know your findings.

Regards,

Mario

0 Kudos

1,517 Views
mferrari1
Contributor III

Hi Mario –

I am using the JN5169-001-M06-2Z Module. On this module, I am using Pin-1 for ADC1 and Pin-27 for ADC2.

Originally, I did not have the call to vAHI_ProtocolPower(), but even without this call it did not work. I included it just in case it was needed, but I don’t think it’s needed.

I have removed the call to vAHI_ProtocolPower( ) as you suggested, but see no improvement.

I have read the “Analog Peripherals” and the “Analog Peripheral Functions” sections of the “JN516x Integrated Peripherals API User Guide” (JN-UG-3087).

I am using Beyond Studio for NXP along with the Beyond Debug Key. When doing the test you requested, I set breakpoints and found that it appears to be the function vAHI_ApSetBandGap( E_AHI_AP_BANDGAP_ENABLE ) which does not return.

This is true whether I have the call to vAHI_ProtocolPower(TRUE) before it or not…

I’m wondering if there might be some other function, like a Clock Enable or something that needs to happen? Do I need to delay for some time period after calling vAHI_ApConfigure() before I call vAHI_ApSetBandGap()?

JN5169-001-M06-2Z Pin-27 is shared VREF/ADC2 do I need to do something to indicate that Pin-27 is for ADC2 and NOT VREF? In vAHI_ApConfigure() I AM providing the E_AHI_AP_INTREF parameter, NOT E_AHI_AP_EXTREF.

I would think this ADC configuration should be straight forward (as described in the User Guide), I’m doing everything the User Guide says to do, but something’s not right…

I appreciate your help with this and am hoping we can get this figured out.

Thanks Mario,

Matt

0 Kudos

1,517 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Matt.

I am checking by my side.

Is the device in sleep mode? Is this issue happen when you are not debugging?

I ran some test, I did work with the JN-AN-1218. Could you please try to flash the DimmableLight example. I want to confirm the JN is not damage.

PUBLIC void APP_vManageTemperatureInit(void)
{
    /* set up the ADCS on platforms that dont already use them */

    /* Set up the analogue peripherals ready to handle the conversions */
    vAHI_ApConfigure(E_AHI_AP_REGULATOR_ENABLE,
    E_AHI_AP_INT_DISABLE,
    E_AHI_AP_SAMPLE_2, //5
    E_AHI_AP_CLOCKDIV_500KHZ,
    E_AHI_AP_INTREF);

    DBG_vPrintf(TRUE, "\nAPP: E_AHI_AP_BANDGAP_ENABLE ");
    vAHI_ApSetBandGap( E_AHI_AP_BANDGAP_ENABLE );

    DBG_vPrintf(TRUE, "\nAPP: InitManageTemperature ");
    while (!bAHI_APRegulatorEnabled());   /* spin on reg not enabled */

    DBG_vPrintf(TRUE, "\nAPP: bAHI_APRegulatorEnabled Done");
}

pastedImage_1.png

Regards,

Mario

0 Kudos

1,517 Views
mferrari1
Contributor III

Hi Mario –

I am not using Sleep Mode. The issue happens whether I am debugging (JTAG via Beyond Studio for NXP IDE) or not debugging.

I have tried it on two different boards, so I expect that it is not due to a damaged part.

I have attached some screenshots for you.

In the screenshot, you will see that I am using the same code as you provided.

I did try adding the call to vAHI_ProtocolPower( TRUE ), but it fails just the same with or without this call.

You can see on my TeraTerm Screenshot that the code hangs when vAHI_ApSetBandGap() is called, I never get to the next DBG_vPrintf().

I have also included a screenshot of what happens when the Debugger is running and it hits this call.

Everything else in my code runs fine, I’m using many peripherals (SPI, SCI, Timers, EEPROM, etc) they all are working with no problem.

The 802.15.4 Stack runs fine and communicates wirelessly with other nodes just fine.

I am running the CPU Clock at 32MHz. I even tried leaving it at the default 16MHz out of Reset, but that didn’t help.

There has to be an explanation for this – something else that’s not set right, or something that’s missing – why would the call to vAHI_ApSetBandGap() hang?

I was unable to locate the project you suggested I flash (JN-AN-1218) if you can send me the zipped project I can try flashing it, although it may have either Hardware or Firmware dependencies which might cause trouble when trying to load it onto my Hardware.

I hope you can ask your resources and find out what conditions would cause the call to vAHI_ApSetBandGap() to not return. Knowing that might help identify the problem.

Thank you for your help Mario,

Matt

0 Kudos

1,517 Views
mferrari1
Contributor III

Hi Mario –

I am using the JN5169-001-M06-2Z Module. On this module, I am using Pin-1 for ADC1 and Pin-27 for ADC2.

Originally, I did not have the call to vAHI_ProtocolPower(), but even without this call it did not work. I included it just in case it was needed, but I don’t think it’s needed.

I have removed the call to vAHI_ProtocolPower( ) as you suggested, but see no improvement.

I have read the “Analog Peripherals” and the “Analog Peripheral Functions” sections of the “JN516x Integrated Peripherals API User Guide” (JN-UG-3087).

I am using Beyond Studio for NXP along with the Beyond Debug Key. When doing the test you requested, I set breakpoints and found that it appears to be the function vAHI_ApSetBandGap( E_AHI_AP_BANDGAP_ENABLE ) which does not return.

This is true whether I have the call to vAHI_ProtocolPower(TRUE) before it or not…

I’m wondering if there might be some other function, like a Clock Enable or something that needs to happen? Do I need to delay for some time period after calling vAHI_ApConfigure() before I call vAHI_ApSetBandGap()?

JN5169-001-M06-2Z Pin-27 is shared VREF/ADC2 do I need to do something to indicate that Pin-27 is for ADC2 and NOT VREF? In vAHI_ApConfigure() I AM providing the E_AHI_AP_INTREF parameter, NOT E_AHI_AP_EXTREF.

I would think this ADC configuration should be straight forward (as described in the User Guide), I’m doing everything the User Guide says to do, but something’s not right…

I appreciate your help with this and am hoping we can get this figured out.

Thanks Mario,

Matt

0 Kudos