Clear Output LPC-LINK 1227

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

Clear Output LPC-LINK 1227

578 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eliveltonsantos on Sun Dec 30 20:38:13 MST 2012
Hello,

I'm new in ARM Programming so I need some help.
I trying turn off a LED from pin 0.9 at LPC-LINK using LPC1227.

Follow down my source code:

[PHP]/*
===============================================================================
Name        : main.c
Author      : Elivélton Santos
Version     : 1.01
Copyright   : Copyright (C)
Description : Only down state a pin
===============================================================================
*/

#ifdef __USE_CMSIS
#include "LPC122x.h"
#endif

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

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

int main(void)
{
LPC_GPIO0 -> DIR = (1 << 9);
LPC_GPIO0 -> CLR = (1 << 9);

while (1) ;
return 0 ;
}[/PHP]

It's right build, but if I press "Program Flash" and see the voltage on pin 0.9, always 3.24V.

What I'm doing wrong?
I hope that somebody helps me. See you.
0 Kudos
17 Replies

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArtjomGromak on Mon Dec 31 10:47:14 MST 2012

Quote: eliveltonsantos
And I need configure any register informing the crystal clock or it takes automatic?
For example, on Microchip PIC I need write on top of the program [I]#USE DELAY (CLOCK = 20000000)[/I] if I'm using a 20MHz XTAL.

And PLL, where can I find out it?


LPC12 started with Internal RC oscilator(12 or 8 MHz). Your program can select other clock source - quart, PLL and other.
Read user manual and look code samples from NXP.
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eliveltonsantos on Mon Dec 31 10:38:39 MST 2012
Thanks, Zero!
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArtjomGromak on Mon Dec 31 10:31:21 MST 2012

Quote: Zero
...or CMSIS (system_LPC122x.c)

  /* System clock to the IOCON needs to be enabled or
  most of the I/O related peripherals won't work. */
  LPC_SYSCON->SYSAHBCLKCTRL = 0x0001001FUL;



Thanks, Zero.
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Dec 31 10:31:06 MST 2012
Look in your CMSIS: SystemInit() in system_LPC122x.c and read UM10441 :eek:
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eliveltonsantos on Mon Dec 31 10:22:29 MST 2012
And I need configure any register informing the crystal clock or it takes automatic?
For example, on Microchip PIC I need write on top of the program [I]#USE DELAY (CLOCK = 20000000)[/I] if I'm using a 20MHz XTAL.

And PLL, where can I find out it?
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Dec 31 10:10:57 MST 2012

Quote: eliveltonsantos
So, if I wanna use ADC: I need change the [I]LPC_SYSCON -> SYSAHBCLKCTRL[/I] to [B]Enables Clock for ADC[/B]?



Yes, no clock -> no fun :)

Look in SYSAHBCLKCTRL register and set bit 14 for ADC clock :D
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eliveltonsantos on Mon Dec 31 10:03:41 MST 2012
So, if I wanna use ADC: I need change the [I]LPC_SYSCON -> SYSAHBCLKCTRL[/I] to [B]Enables Clock for ADC[/B]?
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Dec 31 09:45:19 MST 2012

Quote: ArtjomGromak
very strange...




...or CMSIS (system_LPC122x.c)

  /* System clock to the IOCON needs to be enabled or
  most of the I/O related peripherals won't work. */
  LPC_SYSCON->SYSAHBCLKCTRL = 0x0001001FUL;
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArtjomGromak on Mon Dec 31 09:27:51 MST 2012

Quote: Zero
Something wrong with LPC1227 blinky sample :confused:

    LPC_SYSCON->SYSAHBCLKCTRL |= 0xE001001FUL;



very strange.
After reset clock for gpio and ioconfig enabled. Or not?
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eliveltonsantos on Mon Dec 31 09:05:33 MST 2012
Ok. I'll try to use input now. :o

Thank you so much Zero, [I]dragilla [/I]and [I]ArtjomGromak[/I].
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Dec 31 08:56:37 MST 2012
To program your target, use 'Program Flash' and SWD (no need to use JTAG) :)

To debug your target use 'Debug' :):)
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eliveltonsantos on Mon Dec 31 08:43:32 MST 2012
I added only that line on program and now it's working.

[PHP]int main(void)
{
LPC_SYSCON->SYSAHBCLKCTRL |= 0xE001001FUL; // <- Now It's Ok
LPC_GPIO0 -> DIR = (1 << 9);
LPC_GPIO0 -> CLR = (1 << 9);

while (1) ;
return 0 ;
}[/PHP]

My next question is about LPCXpresso 5.
What about steps for download the program to Target LPC-Link?
First time, "build" the project and press "Program Flash" (check or not "Use JTAG interface"?)? And in other times, repeat it? To press "debug"?
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Dec 31 08:10:59 MST 2012
Something wrong with LPC1227 blinky sample :confused:

/***********************************************************************
 * $Id:: main.c 6922 2011-03-23 17:20:21Z nxp28548                     $
 *
 *     Copyright (C) 2010 NXP Semiconductors.
 *
 * Description:
 *     Simple LED Blinky example. Uses SysTick timer to generate 1ms
 *     tick events.
 *
 ***********************************************************************
 * Software that is described herein is for illustrative purposes only
 * which provides customers with programming information regarding the
 * products. This software is supplied "AS IS" without any warranties.
 * NXP Semiconductors assumes no responsibility or liability for the
 * use of the software, conveys no license or title under any patent,
 * copyright, or mask work right to the product. NXP Semiconductors
 * reserves the right to make changes in the software without
 * notification. NXP Semiconductors also make no representation or
 * warranty that such application will be suitable for the specified
 * use without further testing or modification.
 **********************************************************************/
#ifdef __USE_CMSIS
#include "LPC122x.h"
#endif

#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 ;

volatile uint32_t msTicks=0;

// ****************
//  SysTick_Handler
void SysTick_Handler(void)
{
    msTicks++;
}

int main(void)
{
    /* Enable all three GPIO blocks and IOCON */
    LPC_SYSCON->SYSAHBCLKCTRL |= 0xE001001FUL;
    LPC_GPIO0->DIR = 1 << 7;
    LPC_GPIO0->SET = 1 << 7;

    /* Generate 1ms Ticks */
    SysTick_Config(SystemCoreClock / 1000);

    while (1)
    {
        switch (msTicks)
        {
        case 500:
            msTicks = 0;
            LPC_GPIO0->CLR = 1 << 7;
            break;
        case 100:
        case 200:
        case 300:
            LPC_GPIO0->NOT = 1 << 7;
            break;
        }
        __WFI();
    }
}
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dragilla on Mon Dec 31 08:09:43 MST 2012
I don't have your hardware. I'm on LPCXpresso1769. But I guess it's similar.
I use CMSIS1.3. This is a sample code (here p2.12 as input)
PINSEL_CFG_Type PinCfg; // Pin configuration

// P2.0
PinCfg.Funcnum = 0;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = PINSEL_PINMODE_PULLDOWN;
PinCfg.Portnum = 2;
// pin for wheelie sensor (P2.12)
PinCfg.Pinnum = 12;
PINSEL_ConfigPin(&PinCfg);

// wheelie
FIO_ByteSetDir(2, 1, WHEELIE, 0);
FIO_ByteClearValue(2, 1, WHEELIE);

If you want output jest set DIR to 1 and then use FIO_ByteSetValue function.

Hope this helps.
Cheers
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by eliveltonsantos on Mon Dec 31 07:59:23 MST 2012
Can anyone post any sample code for example test for me?
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dragilla on Mon Dec 31 07:25:53 MST 2012
I think you must set the pin to the right function first.
Read about pin function select registers AFAIR.
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArtjomGromak on Mon Dec 31 06:11:37 MST 2012
May gpio clock is turned off?
0 Kudos