Created
June 12, 2016 06:10
-
-
Save inkwisit/f8f763bae15fd837bc69789743ef37bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define PINSEL4 0x4002C010 | |
#define PINMODE4 0x4002C050 | |
#define PCONP 0x400FC0C4 | |
#define PINMODE_OD2 0x4002C070 | |
#define FIO2DIR 0x2009C040 | |
#define FIO2SET 0x2009C058 | |
#define FIO2CLR 0x2009C05C | |
int delay_ms(unsigned long millisecond) | |
{ | |
unsigned long i=0,j=0; | |
for(i=0;i<millisecond;i++) | |
for(j=0;j<23000;j++); | |
return 0; | |
} | |
int main() | |
{ | |
// want to blink the LED at PORT 2.2 only .. | |
// selecting the power on function for the GPIOs. | |
// PINCON register bit 15 (1) | |
// The reset value is 1 so no need to configure this bit | |
*((unsigned long *)PCONP) |= (1<<15); | |
// configuring the PINSEL4 (add = 0x4002 C010) | |
// selecting the function0 in PINSEL register .. | |
*((unsigned long *)PINSEL4) &= ~(unsigned long)((1<<5)|(1<<4)); | |
// now configuring the PINMODE register to enable the internal pull up register .. | |
//selecting the 00 in PINMODE4 bit 5,4 | |
*((unsigned long *)PINMODE4) &= ~(unsigned long)((1<<5)|(1<<4)); | |
// now configuring the open drain mode of the particular pin | |
// I don't want it to be open drain so bit 2 should be 0 (reset value is 0 so no need to configure it) | |
*((unsigned long *)PINMODE_OD2) &= ~((unsigned long)(1<<2)); | |
// now configuring the GPIOs | |
// FIODIR FIO2DIR - 0x2009 C040 | |
// setting the bit as output .. | |
*((unsigned long *)FIO2DIR) |=(unsigned long)(1<<2); | |
while(1) | |
{ | |
// now setting the register .. | |
*((unsigned long *)FIO2SET) |= (unsigned long)(1<<2); | |
delay_ms(1000); | |
*((unsigned long *)FIO2CLR) |= (unsigned long)(1<<2); | |
delay_ms(1000); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment