lpcware

Accessing GPIOin LPC812

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 18, 2016 by lpcware
Content originally posted in LPCWare by Karthik Venkatesh on Wed Mar 02 00:31:57 MST 2016
Hi,

Following is a simple GPIO access code which I am trying, to learn 812 chip programming.

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


#include "LPC8xx.h"

#define SYSAHBCLKCTRL(*(unsigned long *)0x40048080)
#define DIR0(*(unsigned long *)0xA0002000)
#define PIN0(*(unsigned long *)0xA0002100)
#define SET0(*(unsigned long *)0xA0002200)

int main(void) {
/* Enable GPIO peripheral clock */
SYSAHBCLKCTRL=(1<<6);
DIR0=0xffffffff;
PIN0=0xa5a5a5a5;

    while(1) {

    }
    return 0 ;
}


My Setup:
    IDE -> LPCxpresso
    Flash Magic



If you see the code,
SYSAHBCLKCTRL=(1<<6);  -> This enables the clock for GPIO peripheral
DIR0 = 0xffffffff;  -> This configures all the GPIOs as output
PIN0 = 0xa5a5a5a5; -> Making few pins HIGH and few pins LOW.

I am not getting the expected output. I observed all the GPIOs are HIGH (3.3V) instead.

Note:
To start with, I dont want to make use of the CMSIS or redlib or lpcopen libraries. That is why I myself mapped variables to corresponding 32 bit register addresses using #define.

Please let me know what am doing wrong.

Thanks and regards,
Karthik

Outcomes