Help GPIO

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

Help GPIO

260 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by joaopeddro on Sat Oct 08 14:43:06 MST 2011
I have several questions to configure the pins as GPIO in lpcxpresso  lpc1769,

a)I want turn on e turn off a LED  that are physically connected to the lpcxpresso in  pin P0.22. The datasheet of lpc1769 inform to put Pin P0.22 as output i need  put  1 in the  bits 12,13 an use register  FIOD0, I did it this way : LPC_GPIO0->FIODIR0 = 0x0003000;

b)To turn off all the LEDs i did : LPC_GPIO0->FIOCLR0 = 0x0003000;

The problem is the Led don´t turn on.

The  program is example GPIO  :

#include <cr_section_macros.h>
#include <NXP/crp.h>

// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

#include "lpc17xx.h"
#include "type.h"
// Led 1 is P0_22
#define LED_2 (0 << 22)
int main (void)
{   
  uint32_t i, j;

  /* SystemClockUpdate() updates the SystemFrequency variable */
  SystemClockUpdate();


  LPC_GPIO0->FIODIR0 = 0x0003000;/* P0.22 defined as Outputs */
  LPC_GPIO0->FIOCLR0 = 0x0003000;/* turn off all the LEDs */

  while(1)
  {
for(i = 0; i < 8; i++)
{
  LPC_GPIO0->FIOSET0 = 1 << i;
  for(j = 1000000; j > 0; j--);
}
LPC_GPIO0->FIOCLR0 = 0x0003000;
for(j = 1000000; j > 0; j--);
  }
}
0 Kudos
1 Reply

213 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Oct 08 15:05:39 MST 2011

Quote: joaopeddro
The datasheet of lpc1769 inform to put Pin P0.22 as output i need  put  1 in the  bits 12,13 an use register  FIOD0, I did it this way : LPC_GPIO0->FIODIR0 = 0x0003000;}



No, nonsense :eek:

Use:
#define LED1 (1 << 22)
 ...
LPC_GPIO0->FIODIR |= LED1   /* P0.22 defined as Output */
LPC_GPIO0->FIOCLR = LED1;   /* turn off LED1 */
LPC_GPIO0->FIOSET = LED1;   /* turn on LED1 */
  ...
0 Kudos