Problem configuring xDot analogIn pin

Home Forums mDot/xDot Problem configuring xDot analogIn pin

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #16262
    Chad Goyette
    Participant

    I am currently using the dot examples auto_ota as a template for my new code and am having trouble getting my Analog inputs configured properly. The issue occurs when trying to connect to the lora network in if the xDot fails to connect it goes to sleep and retries a few seconds later. after this happens the AnalogIn object fails to properly read the ADC (all i read is 0). if i disable the sleep function in dot-util.cpp in the join_network() funtion and just replace it with a wait(delay_s) the AnalogIn object works properly when read and everything is great. what should i do to fix this? The AnalogIn object is assigned to PB_0.

    #16263
    Mike Fiore
    Blocked

    Chad,

    Try deleting the AnalogIn object before going to sleep and creating a new one after waking up.

    Cheers,
    Mike

    #16266
    Chad Goyette
    Participant

    I tried this and this doesnt seem to work. It seems that once the xdot goes to sleep i lose the ability to configure the pins to use the adc.

    #16272
    Mike Fiore
    Blocked

    Chad,

    That is strange. Can you post or link to code that demonstrates the issue? It would also be good to know some more about your setup:
    * is your xDot an xDot-DK or on a custom board?
    * how is it getting powered?
    * what’s hooked up to the analog input?
    * anything else you think might be helpful

    Cheers,
    Mike

    #16273
    Chad Goyette
    Participant

    *xDot is on a custom board.
    *the device is being powered with 3.3v from a test power supply.
    *This particular input is connected to a 10k thermistor with a voltage divider circuit.
    *I have tried additional unused pins that where left floating (open) with same result.

    For code I am using the dot examples auto_ota as a template (basically using all the startup stuff and then replacing the “guts with my code”. My custom board uses two inputs PB_0 on the ADC, and PB_14 as a digital in. The digital in object works fine.
    if the board doesn’t go to sleep the ADC works as expected, once it sleeps i only get 0. I have tried what you suggested creating and destroying the object before and after sleeping but that is not changing the result.

    #16275
    Chad Goyette
    Participant

    I just created very simple helloworld program that is demonstrating the issue. on the first loop i am reading the ADC correctly, on the second loop and then on it will read 0. I am using libxDot-mbed5 revision 7:aff2c05 and all the dot examples supporting files.

    ————————————————————
    #include “dot_util.h”
    #include “RadioEvent.h”
    #if ACTIVE_EXAMPLE == HELLOWORLD

    //AnalogIn tmp3(PB_0);
    mDot* dot;

    main()
    {
    dot = mDot::getInstance();
    int a = 0;
    while(1)
    {
    AnalogIn tmp3(PB_0);
    a++;
    uint16_t TC = tmp3.read_u16();
    printf(“Raw thermistor reading is %i\r\n”, TC);
    printf(“Hello World this is the Target Device %i\r\n”, a);
    //wait(1);
    delete &tmp3;
    dot->sleep(5, mDot::RTC_ALARM, false);
    }
    }
    #endif
    —————————————————————-

    #16276
    Jason Reiss
    Keymaster

    Try to allocate the pin object dynamically.

    AnalogIn *tmp3 = new AnalogIn(PB_0);

    uint16_t TC = tmp3->read_u16();

    delete tmp3;

    #16277
    Chad Goyette
    Participant

    I just tried this with no luck.

    #16278
    Peter Ferland
    Blocked

    Hi Chad,
    Do you have deep_sleep set to true or false? If you have it set to “true” can you see if there is a different behavior for false?
    What version of libxDot mbed-os are you using?

    There is an old mbed bug for the STM32L1 series related to improper clock setup after restart from deep sleep. More detail including a resolution can be found on the mbed forum here: https://developer.mbed.org/questions/52467/Cant-read-ADC-after-WakeUp-from-deepslee/
    Can you try putting the commands for manually resetting the HSI clock from the answer in that thread after the sleep command?

    #16279
    Chad Goyette
    Participant

    I have tried both deepsleep true and false with no change.
    mbed-os version 2246:a6f3fd1 which should be 5.1.5.

    #16280
    Chad Goyette
    Participant

    Ok i tried the HSI clock restart and that worked. is there a more permanent fix for this or is this the best we have at the moment?

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.