SWD dowloading and GPIO pins LPCXPresso LPC1114

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

SWD dowloading and GPIO pins LPCXPresso LPC1114

622 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Vit_Ciola on Wed Nov 23 06:33:07 MST 2011
Hi,

This is my first project with the LPCXpresso 1114, and during the development I'm facing some problems:

-I did a schematic based on the LPCXpresso target board. Im using the SWD interface, so it is mandatory to have the external cristal?

-I selected some pins, that in the silk are printed with other functions with the other functions like:
 
   -P0_1 - FT/GPIO;
   -P0_4 - I2C - SDA;
   -P0_5 - I2C - SCL;
   -P0_8 - MISO;
   -P1_4 - AD5;
   -P1_6 - RXD;

I am using the CMSIS function GPIOSetDir, but with these pins I couldnt set as an IO.

Do you know what can I be doing wrong?
0 Kudos
9 Replies

594 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Vit_Ciola on Thu Nov 24 05:28:29 MST 2011
Now it's working!!

Thanks a lot Zero and Rob65 for these very usefull tips!:D
0 Kudos

594 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Vit_Ciola on Thu Nov 24 05:27:13 MST 2011
Now it's working!

Thanks a lot Zero and Rob65 for these very usefull tips!
0 Kudos

594 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Nov 23 12:32:34 MST 2011

Quote:

Actually there is no Pull-up for the P0_1.

Beginner mistake :rolleyes:


Quote:

But in the LPCXpresso board this pin is not pulled-up right?

Yes, if you're lucky, you don't need it. If you connect something to this pin, your luck is over...


Quote:

So to select the IRC source I should change the MAINCLKSEL to 0x00?

No. This settings are done in system_LPC11xx.c via #defines

#define SYSPLLCLKSEL_Val      0x00000001
is default setting for System Oscillator. Change it to 0 for IRC.
If you change MAINCLKSEL to IRC, you are working with 12MHz main clock (=IRC) and without PLL.
If you change SYSPLLCLKSEL your PLL is changing input source, but generating 48MHz main clock via PLL.


Quote:

Set do you mean eneable as a GPIO Pin? Not set the output pin, right?

No, in this case user manual shows pin function 1 = MISO0. You have to check pin functions in chapter 7 :eek:
0 Kudos

594 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Vit_Ciola on Wed Nov 23 11:41:40 MST 2011
The Reset Pull-up value is 12k.

Actually there is no Pull-up for the P0_1. I'm trying  to use it as an output, it is connected with driver which will feed the motor, I'll force a pull-up externally.

But in the LPCXpresso board this pin is not pulled-up right?


Quote: Zero

#3 Did you check your SystemInit? Did you change your clock source to IRC there?



So to select the IRC source I should change the [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAINCLKSEL  [SIZE=3][COLOR=#000000]to 0x00?[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]switch[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] (LPC_SYSCON->[/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAINCLKSEL[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] & 0x03) {[/COLOR]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]case[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0: [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Internal RC oscillator */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]SystemCoreClock = __IRC_OSC_CLK;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]break[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]case[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1: [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Input Clock to System PLL */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]switch[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (LPC_SYSCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SYSPLLCLKSEL[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & 0x03) { .........[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][/SIZE]
[SIZE=2] [/LEFT]
[/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]Regarding the IOCONFIG register:



Quote: Zero

 LPC_IOCON->PIO0_8           &= ~0x07;   //reset
 LPC_IOCON->PIO0_8           |= 0x01;    //set



Set do you mean eneable as a GPIO Pin? Not set the output pin, right?
0 Kudos

594 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Wed Nov 23 11:02:00 MST 2011
Schematics ...

Looks like you are using Eagle ? Hint: If you do a right click on your components and select "Smash" the value and name fields of components can be moved independent from the component itself - this gives you the option to move them to a location where you can actually read the values.

The connector SL6 is connected to the LPC-Link's JP4 as follows (I think):[INDENT] SL6.1 - JP4.15
SL6.3 - JP4.11
SL6.4 - JP4.7
SL6.5 - JP4.5
SL6.6 - JP4.3
[/INDENT]
Quote: Vit_Ciola
[SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]
[SIZE=3][COLOR=black]This is not part of the IOCONFIG register right?[/COLOR][/SIZE]
[/COLOR][/SIZE][/COLOR][/SIZE]



Correct. The IOCONFIG registers are bundled in the LPC_IOCON structure.
So the register for P0.1 is LPC_IOCON->PIO0_1 etc.

If you are not sure you can always check the inc/LPC11xx.h file in the CMSIS project.

Rob
0 Kudos

594 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Nov 23 10:39:33 MST 2011

Quote:

when I try to debug the software apparently is downloaded to the micro...

Schematic:

#1 What's your Reset pullup value?

#2 Where's your ISP pullup?

Scope ISP (PI0_1) and Reset. If ISP is longer low than Reset, you're in ISP mode :eek:

So your ISP pullup should be equal or lower than Reset pullup

#3 Did you check your SystemInit? Did you change your clock source to IRC there?

IOCONFIG:
Try something like this:

 LPC_IOCON->PIO0_8           &= ~0x07;   //reset
 LPC_IOCON->PIO0_8           |= 0x01;    //set
0 Kudos

594 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Vit_Ciola on Wed Nov 23 09:10:20 MST 2011

Quote: Zero
No. it's not. But I would strongly suggest to include it, if you are drawing your own board. A small SMD crystal and 2 caps are not very space consuming.
And if you don't need it today, just don't solder it in. Perhaps you are happy some day that there's a place for them left on your board...



[SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]
[/COLOR][/SIZE][/COLOR][/SIZE]
Quote: Rob65
No, you do not need an external crystal - that's the nice thing on these chips: you can use either internal RC oscillator or external resonator/crystal. Just make sure that your software environment does not try to use the main (crystal) oscillator.



Ok. In my board I didnt put the cristal (schematic is attached), so it should work the SWD debug.
But it's not.
Im using the LPCXpresso v 4.0.5, when I try to debug the software apparently is downloaded to the micro, with the following messages in the console:
[SIZE=2][COLOR=red] [/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=red]set remotetimeout 60000[/COLOR][/SIZE][/LEFT]
[COLOR=#ff0000][COLOR=#ff0000][LEFT][SIZE=2]mon ondisconnect cont[/SIZE][/LEFT]
[SIZE=2]set arm force-mode thumb[/SIZE]
[/COLOR][/COLOR]
But when I analyze the signals in the port, they are not the same as in the LPCXpresso 1114 target.

PS: I physically cut the communication between the LPC-Link and Target.


Quote: Zero

Just read UM10398 Chapter 7: LPC111x/LPC11Cxx I/O configuration (IOCONFIG)

Default pin function isn't always GPIO, so don't forget to set I/O configuration registers :eek:




Quote: Rob65

Not giving us enough info to answer?

I can't find any function named GPIOSetDir in my CMSIS project and on my chip I/O pins are either input or output, not IO.
Please explain what you are trying to do.



I read the chapter 7, and I understood that I have to change the register IOCONFIG, but I couldnt found this register in the software...

What I did was to use the function GPIOSetDir ( which I took from the gpio.c file, blink example).  To select some ports as Input and others as Output.

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [B]GPIOSetDir[/B]( [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] portNum, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] bitPosi, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] dir )
{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](dir)
[U]LPC_GPIO[/U][portNum]->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DIR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= 1<<bitPosi;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_GPIO[portNum]->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DIR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~(1<<bitPosi);
}[/LEFT]
[/SIZE][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][B]#endif[/B]


[SIZE=3][COLOR=black]This is not part of the IOCONFIG register right?[/COLOR][/SIZE]
[/COLOR][/SIZE][/COLOR][/SIZE]
0 Kudos

594 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Nov 23 07:10:27 MST 2011

Quote:

-I did a schematic based on the LPCXpresso target board. Im using the SWD interface, so it is mandatory to have the external cristal?


No. it's not. But I would strongly suggest to include it, if you are drawing your own board. A small SMD crystal and 2 caps are not very space consuming.
And if you don't need it today, just don't solder it in. Perhaps you are happy some day that there's a place for them left on your board...


Quote:

but with these pins I couldnt set as an IO.



Just read UM10398 Chapter 7: LPC111x/LPC11Cxx I/O configuration (IOCONFIG)

Default pin function isn't always GPIO, so don't forget to set I/O configuration registers  :eek:
0 Kudos

594 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Wed Nov 23 07:09:40 MST 2011
No, you do not need an external crystal - that's the nice thing on these chips: you can use either internal RC oscillator or external resonator/crystal. Just make sure that your software environment does not try to use the main (crystal) oscillator.


Quote: Vit_Ciola
Do you know what can I be doing wrong?


Not giving us enough info to answer?

I can't find any function named GPIOSetDir in my CMSIS project and on my chip I/O pins are either input or output, not IO.
Please explain what you are trying to do.

Rob
0 Kudos