Hi,
I originally posted this as a question but didn't get a reply, so I did some more checking and I'm pretty sure this is a bug.
I'm using the nRF51822-DK platform, and wanted to delete, or shutdown, PwmOut objects during sleep, as they use a bit of background power.
The app kept crashing so I've created a simple app to test, and yep it crashes after 2 cycles
/* testing power consumption
PwmOut dynamic allocation not working
*/
#include "mbed.h"
int main() {
PwmOut *ptr;
while(1) {
ptr = new PwmOut(LED1);
ptr->write(0.5);
wait(1);
ptr->write(1);
wait(1);
delete ptr;
}
}
LED flashes twice then program goes nuts, all LEDs blink randomly.
I'm assuming this object supports dynamic allocation, since I've read in many other posts people wanted to delete objects to save power. I also think the object is not deleting correctly, and after a quick look in src, found that there's no desctructor for this object, but not sure if that's normal, and tbh am a little cautious about changing something after just a quick inspection.
Looking forward to suggestions or comments
Thanks in advance
Andrew
Hi,
I originally posted this as a question but didn't get a reply, so I did some more checking and I'm pretty sure this is a bug.
I'm using the nRF51822-DK platform, and wanted to delete, or shutdown, PwmOut objects during sleep, as they use a bit of background power.
The app kept crashing so I've created a simple app to test, and yep it crashes after 2 cycles
LED flashes twice then program goes nuts, all LEDs blink randomly. I'm assuming this object supports dynamic allocation, since I've read in many other posts people wanted to delete objects to save power. I also think the object is not deleting correctly, and after a quick look in src, found that there's no desctructor for this object, but not sure if that's normal, and tbh am a little cautious about changing something after just a quick inspection.
Looking forward to suggestions or comments
Thanks in advance Andrew