mdot wakeup after deep sleep not reading PA_0

Home Forums mDot/xDot mdot wakeup after deep sleep not reading PA_0

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12666
    frank boddeke
    Participant

    hi

    i got a weird problem with reading pa_0 with the internal pull ups engaged. seems that after wakeup from deep sleep the internal pull up is not engaged. i put a volt meter on the port pa_0, nothing else. bare board, not in the programmer, just connected: gnd, 5volt, pa_2 connected to usb-serial-device and pa_0 to voltmeter.

    what i see is after power-up pa_0 has 3.00 volt till sleep where it drops to 0 volt. that all is nice. but after wake-up/restart the pin stays at 0 volt (and reads 0). looks to me like the internal pull up is not engaged?

    any ideas why this does not work?

    thanks frank

    my code:

    #include "mbed.h"
    #include "rtos.h"
    #include "mDot.h"
    #include "MTSLog.h"
    #include "MTSText.h"
     
    using namespace mts;
     
     
    #define REED_PORT   PA_0
     
    RawSerial pc(PA_2,NC);
     
    volatile int reed_has_changed = 0;
     
    void isr_reed_sensor_change(void) {
        reed_has_changed++;
    }
     
     
    main() {
        
        pc.baud(115200);
        
        pc.printf("Build: " __DATE__ ", " __TIME__"\r\n");
        
        mDot* dot = mDot::getInstance();
        dot->setLogLevel(MTSLog::TRACE_LEVEL);
     
         
        DigitalIn reed_sensor(REED_PORT);
        reed_sensor.mode(PullUp);
     
        InterruptIn reed_sensor_change(REED_PORT);
        
        reed_sensor_change.fall(&isr_reed_sensor_change);
        reed_sensor_change.rise(&isr_reed_sensor_change);
        reed_sensor_change.mode(PullUp);
        
        while(1) {
            
             for(int i=0;i<10;i++) {
             
                pc.printf("changes %d %d\r\n",reed_has_changed,reed_sensor.read());
                wait(1.0);
             }
             
             dot->sleep((int)5, mDot::RTC_ALARM_OR_INTERRUPT, true);
        }
    }

    output:

    Build: May 25 2016, 08:58:47
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    Build: May 25 2016, 08:58:47
    changes 0 0
    changes 0 0
    changes 0 0
    changes 0 0
    changes 0 0
    changes 0 0
    changes 0 0
    changes 0 0
    changes 0 0
    ….

    #12668
    frank boddeke
    Participant

    added an external 100k pullup to 5 volt:

    now reed 3.37 volt till sleep and from then on 1.39 volt and output as below. something is pulling down starting when going to deep sleep

    still no idea why the first (cold) startup is different from the startup after deep sleep

    Build: May 25 2016, 08:58:47
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    changes 0 1
    Build: May 25 2016, 08:58:47
    changes 0 0
    changes 33403 0
    changes 66763 0
    changes 100220 0
    changes 133611 0
    changes 166794 0
    changes 200154 0
    changes 233781 0
    changes 267399 0
    changes 301376 0

    #12741
    frank boddeke
    Participant

    Hi Frank,

    Here is a solution:
    mDot* dot = mDot::getInstance();
    dot->setLogLevel(MTSLog::TRACE_LEVEL);
    if(dot->getStandbyFlag()){
    PWR->CSR &= ~PWR_CSR_EWUP;
    }

    Explanation:
    When the mdot is placed in deep sleep with wake on INTERRUPT or RTC_ALARM_OR_INTERRUPT, the only pin that can be used as the interrupt to wake it is PA_0. In that case, the bit below is set to one. So upon reset/power up, we need to clear that bit if we are coming out of standby(deep sleep) mode.

    From the ST Micro reference guide…
    “Bit 8 EWUP: Enable WKUP pin
    This bit is set and cleared by software.
    0: WKUP pin is used for general purpose I/O. An event on the WKUP pin does not wakeup the device from Standby mode.
    1: WKUP pin is used for wakeup from Standby mode and forced in input pull down configuration (rising edge on WKUP pin wakes-up the system from Standby mode).
    Note: This bit is reset by a system reset.”

    I will enter a ticket in our tracking system to provide a fix that will not require the user’s application to mess with it. Let me know if the above solution is reasonable fix for you in the mean time.

    Kind regards,
    Leon

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