0
\$\begingroup\$

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.

\$\endgroup\$
6
  • \$\begingroup\$ In the first application, you are writing straight to the output register which is very fast, and then doing it again instantly. This may result in high-frequency EMI generation which might be causing the apparent brownout. If you were to add a wait or delay in the loop, it would reduce the EMI. Could you try this and let me know? I am not seeing another reason that could cause this. \$\endgroup\$
    – MIL-SPEC
    Jun 18, 2018 at 10:34
  • \$\begingroup\$ I removed the while loop. Runs as normal with the USB supply, but still experiencing issues with the 5v supply. This is extremely odd. \$\endgroup\$
    – 19172281
    Jun 18, 2018 at 10:42
  • \$\begingroup\$ Perhaps it doesn't like me turning on all the port 1 pins, most of which aren't being used. \$\endgroup\$
    – 19172281
    Jun 18, 2018 at 10:44
  • \$\begingroup\$ Modify your original code so that only four bits of P1 are affected. Other bits of P1 may have functions that you shouldn't modify. \$\endgroup\$ Jun 18, 2018 at 12:24
  • \$\begingroup\$ I'll give it a go, but why would it work with the USB supply then? \$\endgroup\$
    – 19172281
    Jun 18, 2018 at 13:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.