m
m
Line 36: Line 36:
 
}
 
}
 
}
 
}
 +
 +
 +
{{DISQUS}}

Revision as of 12:07, 17 March 2015

Amruta (talk) 11:24, 17 March 2015 (IST)


Basics

lpc17xx header file

This is peripheral access header file for NXP LPC17xx device series. It contains all required register and peripheral definitions which one requires in order to access any peripheral.

PINSEL and GPIO

Schematic

Code

#include "lpc17xx.h"   // NXP Library containing all port abd register definations
#include "stdutils.h"  // Explore Embedded library
 
#define LED		29	 //P1.29
#define SWITCH         28	 //P1.28
int main()
{
        SystemInit();
 
	LPC_PINCON->PINSEL3 = 0x00;			   // Configure Pin as GPIO
	util_BitSet(LPC_GPIO1->FIODIR,LED);	   	   // Set pin direction as output
	util_BitClear (LPC_GPIO1->FIODIR,SWITCH);	   // Set pin direction as input
 
	while(1)
	{		
		if (util_IsBitCleared (LPC_GPIO1->FIOPIN,SWITCH))	// check if switch is pressed
			util_BitSet (LPC_GPIO1->FIOSET,LED);	   // turn on LED	
		else
			util_BitSet (LPC_GPIO1->FIOCLR,LED);	// turn off LED	
	}
}
 
 
{{DISQUS}}