Disabled Port output

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Disabled Port output

977 Views
lpcware
NXP Employee
NXP Employee

Content originally posted in LPCWare by Thucydides on Sun May 20 00:46:06 MST 2012
Hello,

I encountered a strange behavior of LPC1343's port output.
For just blinking LED I used following 10 ports.
P1.1, P1.10, P0.7, P2.0, P1.7, P1.6, P0.11, P1.2, P1.5, P1.0
But only three ports (P1.10, P0.7, P1.5) was justly toggled but other ports didn't work.
For example as for P1.10, it once rose High and remained High ever.
Anyone knows why such behavior occurs?
After that I added here IO config codes before GPIOSetDir() but the result was same.

Thanks,
Thucydides
http://knowledgebase.nxp.com/member.php?u=1317

My source codes.

struct ENABLE_PIN {
    unsigned char port_num;
    unsigned char bit_num;
};
struct ENABLE_PIN enable_pin[10] = {
    {1, 1}, {1, 10}, {0, 7}, {2, 0}, {1, 7}, {1, 6}, {0, 11}, {1, 2}, {1, 5}, {1, 0},
};

// Enable AHB clock to the GPIO domain.
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
for (i=0; i < 10; i++){
// ** I added here IO config codes later
    GPIOSetDir(enable_pin.port_num, enable_pin.bit_num, 1);
}

while (1)
{
    for (i=0; i < 10; i++){
        GPIOSetValue(enable_pin.port_num, enable_pin.bit_num, 1);
        delay32Ms(0, 250);
        GPIOSetValue(enable_pin.port_num, enable_pin.bit_num, 0);
          delay32Ms(0, 250);
    }
}

0 Kudos
Reply
4 Replies

886 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by vasanth on Sun May 20 23:25:18 MST 2012

Quote:

LPC_IOCON->PIO2_0 &= ~0x0000000037;

This is a 32 bit register and you are dealing with 40 bit numbers.:eek:

Double check all your magic numbers.
and use debugger as previously suggested.
0 Kudos
Reply

886 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun May 20 02:11:01 MST 2012
Debugger is your friend :)


Quote:

How should I do for it??

First thing to do is always to check the actual setting with your debugger :rolleyes:
So what is your debugger telling you about IOCONFIG ?

Is it really GPIO and output, or did you fail to switch (or some other init routine did change this setting meanwhile :eek:) ?
0 Kudos
Reply

886 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Sun May 20 01:55:18 MST 2012
Yes I know and I added following IO config description but result was same.
I set R_PIO1_1 as GPIO.
How should I do for it??

    LPC_IOCON->R_PIO1_1 &= ~0x00000036;
    LPC_IOCON->R_PIO1_1 |= 0x00000089;

    LPC_IOCON->PIO1_10 &= ~0x000000003E;
    LPC_IOCON->PIO1_10 |= 0x00000041;

    LPC_IOCON->PIO0_7 &= ~0x0000000037;
    LPC_IOCON->PIO0_7 |= 0x00000008;

    LPC_IOCON->PIO2_0 &= ~0x0000000037;
    LPC_IOCON->PIO2_0 |= 0x00000008;

    LPC_IOCON->PIO1_7 &= ~0x0000000037;
    LPC_IOCON->PIO1_7 |= 0x00000008;

    LPC_IOCON->PIO1_6 &= ~0x0000000037;
    LPC_IOCON->PIO1_6 |= 0x00000008;

    LPC_IOCON->R_PIO0_11 &= ~0x00000016;
    LPC_IOCON->R_PIO0_11 |= 0x00000089;

    LPC_IOCON->R_PIO1_2 &= ~0x00000016;
    LPC_IOCON->R_PIO1_2 |= 0x00000089;

    LPC_IOCON->PIO1_5 &= ~0x0000000037;
    LPC_IOCON->PIO1_5 |= 0x00000008;

    LPC_IOCON->R_PIO1_0 &= ~0x00000016;
    LPC_IOCON->R_PIO1_0 |= 0x00000089;
0 Kudos
Reply

886 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun May 20 01:32:55 MST 2012
Check your pin function in IOCON register. PIO1_1 default IOCON setting isn't GPIO :eek:

Easiest way to check IOCON setting is debugger -> peripheral view :)
0 Kudos
Reply