I've written a very basic program (without the mbed library) to turn on all LEDs on an mbed board (https://os.mbed.com/platforms/mbed-LPC1768/):
#include "lpc17xx.h"
int main (void)
{
SystemInit();
LPC_GPIO1->FIODIR = 0xffffffff; // P1.29 = Outputs
LPC_GPIO1->FIOCLR = 0xffffffff; // Turn-OFF LED
//Loop LED Test
while(1)
{
LPC_GPIO1->FIOSET = 0xffffffff; // Turn-ON LED
}
}
I initially ran the program on the mbed using the standard USB connection, and it worked perfectly, with all LEDs lighting up.
Conversely, when I powered the mbed using a 5v supply (http://www.hobbyandyou.com/adraxx-33v-and-5v-power-supply-module-for-mb102-bread-board), the LEDs light at a lower brightness, and flicker, occasionally switching off briefly.
Naturally, I suspected there was a problem with the 5v supply, but I tried re-writing the program to use the mbed library, and it worked perfectly with the 5v supply (identical brightness, no flicker, etc):
#include "mbed.h"
DigitalOut myled(LED1);
DigitalOut myled1(LED2);
DigitalOut myled2(LED3);
DigitalOut myled3(LED4);
int main() {
while(1) {
myled = 1;
myled1 = 1;
myled2 = 1;
myled3 = 1;
}
}
Based on this, I can only suspect that the original code is somehow not playing nicely with the external supply. Can anyone explain what's happening? I'm completely stumped.
Note, the original program was compiled with MCUXpresso.