lpcware

Help GPIO

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
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--);
  }
}

Outcomes