[SOLVED] Labtool LPC812 PIO0_1 not usable as GPIO?

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

[SOLVED] Labtool LPC812 PIO0_1 not usable as GPIO?

912 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Sun Dec 14 21:56:31 MST 2014
This is a very similar problem as the one in the lpc812-pio01-gpio-problem thread and was discovered while helping to solve the problem there.

Concerning the Labtool's LPC812, I would like to know why there is always a clock signal on PIO0_1 even when the board is powered separately, running release software, and there are no debug connections at all.  According to the Labtool schematic PIO0_1 only goes to an internal header and nowhere else.  Isn't PIO0_1 supposed to be GPIO after a chip reset?

My program for testing in LPCOpen is:

(The second include is 'cr_section_macros.h' without the quotes between left and right carets. How do you enter something between left and right carets in the WYSIWYG editor and have it display?  Seems like a bit of a problem for posting C source code. Program source code is attached.)

/*
===============================================================================
 Name        : GPIO0_1_Test.c
 Author      : $(author)
 Version     :
 Copyright   : $(copyright)
 Description : main definition
===============================================================================
*/

#include "chip.h"
#include <cr_section_macros.h>

const uint32_t OscRateIn = 12000000;
const uint32_t ExtRateIn = 0;

enum PORTS {PORT0};

enum GPIO0PIO  // For the TSSOP20 and SOP20 packages
{PIO0_0,PIO0_1,PIO0_2,PIO0_3,PIO0_4,PIO0_5,PIO0_6,PIO0_7,
PIO0_8,PIO0_9,PIO0_10,PIO0_11,PIO0_12,PIO0_13,PIO0_14,PIO0_15,
PIO0_16,PIO0_17};

enum INOUT {IN, OUT};
enum LOWHIGH {LOW, HIGH};

int main(void) {

SystemCoreClockUpdate();

Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_GPIO);

Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, PORT0, PIO0_1);

Chip_GPIO_SetPinState(LPC_GPIO_PORT, PORT0, PIO0_1, LOW);

// GPIO0_1 should be low, but there is a clock signal there. Why?

    // Force the counter to be placed into memory
    volatile static int i = 0 ;
    // Enter an infinite loop, just incrementing a counter
    while(1) {
        i++ ;
    }
    return 0 ;
}

Original Attachment has been moved to: GPIO0_1_Test.c.zip

Labels (1)
0 Kudos
Reply
2 Replies

803 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Wed Dec 17 01:52:23 MST 2014
    liaochengyi, thank you for the reply, you are absolutely right.  I had to read your post several times before I figured out where to look for where the clkout pin was set.  I finally got it, sysinit.c, and more precisely in board_sysinit.c function SystemSetupMuxing().  Never thought to look at the sysinit and board startup code.  Mystery solved.

This is what I added to the code above to make PIO0_1 work as a usable GPIO pin:
/* Unassign CLKOUT pin, as calls in board_sysinit.c set it to PIO0_1 by default*/
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
LPC_SWM->PINASSIGN[8] = 0xFFFFFFFF;
Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);
0 Kudos
Reply

803 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by liaochengyi on Tue Dec 16 02:39:00 MST 2014
Hi,

I also used LPC812 now.

I checked the result of PIO01 action. It's OK. I can use it to be GPIO.

You need disable the clock out setting of PIO01 in sysinit and set the GPIO register.

:) 
0 Kudos
Reply