Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

can't toggle P2[0..7] of LPC1768 using mbed library

Status
Not open for further replies.

mostafanfs

Member level 1
Joined
Aug 2, 2012
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,611
Hi guys. I've been trying to use mbed library on my LPC1768 board (it's a LandTiger board actually). In this board there are 8 LEDs connected to P2.0 ~ P2.7 and when I try to toggle one of them it wont work at all. Here's the code:
Code:
#include "mbed.h"

DigitalOut myled(P2_0);

int main(void) {
	while(1){
	myled = 1;
	wait_ms(1000);
	myled = 0;
	wait_ms(1000);
	}
}
As you can see it's a simple toggle program. What is strange is that it works inside Keil debugger and I can see that P2.0 is toggling.
What's even more strange is that the program will work fine on the board for all the other Ports besides P2[7..0] (even for P2.8 ~ P2.13 will work fine!) so it's not a problem with clock or start-up code or anything else.
So do we have any thoughts? Why am I getting this strange behavior ?
 

I have not use LPC controllers but maybe the pins on which LEDs doesn't turn ON are open drain type. Put a pullup resistor and see.
 

Thank you. Well I checked and turned out that DigitalOut class does put the GPIO pin mode in No pull-up/down mode and it's ok considering it works fine for all GPIOs besides P2[7..0] . Anyway just to be sure I tried to put a pull-up internally for P2.0 by changing PINMODE register (setting it as Pull-up enabled) inside main function and it didn't work again.
It's ridiculous. I'm going out of my mind!
Does anybody have a LPC1768 mbed board? I really appreciate it if someone tested above example on their mbed board ...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top