Beginner Help with Setup and Programming

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

Beginner Help with Setup and Programming

849 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micro9000 on Mon Jul 01 14:03:30 MST 2013
Hey guys, I have the LPC1764 (ARM Cortex M3) uC and a LPC-Link 2, which I have just received. I have made various connections for VDD, VSS/GND, external resonator, and for SWD  (SWDIO, SWCLK and RESET) and I would like simply make an LED blink. In addition, I have a jumper on JP2 for powering the target uC (JP1 is open).

I then click on the "Program Flash" icon and get a window that says "Program Flash using RedLink." I then click "OK." Now, the problem is when I click "OK" I get the following error message under "Program Flash using RedLink" in red:

"Image File " not found."

What does this error message indicate? Also, is there anything else I should be taking into account when proceeding to program the target device. Thank you.
0 Kudos
14 Replies

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micro9000 on Mon Jul 01 17:21:14 MST 2013
Thanks again. By pressing the debug icon at the top the stop icon is then re-enabled and I can now halt the process and program the uC.

I now see that I am getting an output on pin 56. Thank you.

EDIT:

Here is my basic code for blinking LED just using loops:


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

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

// #define PLL0CFG_Val 0x00090063 ensure this is the case in CMISvp00_17xx under system_LPCxx.c for now
// see user manual section 4.5 for more information on how to get 100MHz

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

// Function to initialize GPIO to access LED2
void led2_init (void)
{
// Set P0_22 to 00 - GPIO
LPC_PINCON->PINSEL1&= (~(3 << 12));
// Set GPIO - P0_22 - to be output
LPC_GPIO0->FIODIR |= (1 << 22);
}


// Function to turn LED2 on
void led2_on (void)
{
LPC_GPIO0->FIOSET = (1 << 22);
}

// Function to turn LED2 off
void led2_off (void)
{
LPC_GPIO0->FIOCLR = (1 << 22);
}


int main(void) {

int x;

led2_init();
led2_on();

while(1) {
led2_on();
for(x=0;x<=2000000;x++){}
led2_off();
for(x=0;x<=2000000;x++){}
}
return 0 ;
}


Also, by going under the build icon and clicking on "Release build" and then clicking on "Debug Build" solves the previously mentioned issues as well.
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Jul 01 17:04:58 MST 2013

Quote: micro9000
Thanks. I found the section with PLL in the user manual (section 4.5) and will have to look it over.

I just have one more problem that occurs. When I program it once, it finishes okay. However, if I try to program it again it says:

"02: Failed on connect: Ep(04). Cannot halt processor." and in the new window at the bottom it says "Target Connection Failed"

I also see that the stop icon (red square) is grayed out. In addition, when I unplug the USB cable for the LPC-Link and then plug it back in and go to program, it then fails and I get a new window that pops up and says:

"Flash driver "Init" timeout (1500ms) PC:100000DE"

The only way I can get it to program successfully again is to restart the compiler, unplug the USB cable for the LPC-Link 2, plug it back in, and then relaunch the compiler. How do I halt the process and prevent these errors from occurring?


You should start to debug your program. If that's not possible after a succesful download your code is not running. So switch to ISP and try it again.
If your program is not working it's time to check the crystal.
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micro9000 on Mon Jul 01 16:45:29 MST 2013
Thanks. I found the section with PLL in the user manual (section 4.5) and will have to look it over.

I just have one more problem that occurs. When I program it once, it finishes okay. However, if I try to program it again it says:

"02: Failed on connect: Ep(04). Cannot halt processor." and in the new window at the bottom it says "Target Connection Failed"

I also see that the stop icon (red square) is grayed out. In addition, when I unplug the USB cable for the LPC-Link and then plug it back in and go to program, it then fails and I get a new window that pops up and says:

"Flash driver "Init" timeout (1500ms) PC:100000DE"

The only way I can get it to program successfully again is to restart the compiler, unplug the USB cable for the LPC-Link 2, plug it back in, and then relaunch the compiler. How do I halt the process and prevent these errors from occurring?
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Jul 01 16:07:02 MST 2013

Quote: micro9000
. I looked at the datasheet and it is a bit unclear to me.



Then look in the User Manual.

Change your CMSIS setup in system_LPC17xx.c

from

#define PLL0CFG_Val           0x00050063

to

#define PLL0CFG_Val           0x00090063


Quote: micro9000
Also, which pin is P0_22 is that pin 56, P0[22]?

Yes.
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micro9000 on Mon Jul 01 15:50:12 MST 2013
Thank you so much for the replies. I have managed to get it working. I'm not entirely sure of the cause I checked my connections, restarted the compiler, etc, and now it works. It could be one was loose.

Anyway, I will also place another 10k resistor in series for the reset to get 20K and I will also place a 10K resistor from pin 1 of the LCP-Link2 for the target supply. Here is a picture of it running:

[IMG]http://i188.photobucket.com/albums/z265/fac7orx/flashcomplete_zpsbe77be02.jpg[/IMG]

Here is the code I am using:

/*
===============================================================================
 Name        : main.c
 Author      : 
 Version     :
 Copyright   : Copyright (C) 
 Description : main definition
===============================================================================
*/

#ifdef __USE_CMSIS
#include "LPC17xx.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 ;

// TODO: insert other include files here

// TODO: insert other definitions and declarations here
// Function to initialise GPIO to access LED2
void led2_init (void)
{
// Set P0_22 to 00 - GPIO
LPC_PINCON->PINSEL1&= (~(3 << 12));
// Set GPIO - P0_22 - to be output
LPC_GPIO0->FIODIR |= (1 << 22);
}


// Function to turn LED2 on
void led2_on (void)
{
LPC_GPIO0->FIOSET = (1 << 22);
}

// Function to turn LED2 off
void led2_off (void)
{
LPC_GPIO0->FIOCLR = (1 << 22);
}

// Function to invert current state of LED2
void led2_invert (void)
{
int ledstate;

// Read current state of GPIO P0_0..31, which includes LED2
ledstate = LPC_GPIO0->FIOPIN;
// Turn off LED2 if it is on
// (ANDing to ensure we only affect the LED output)
LPC_GPIO0->FIOCLR = ledstate & (1 << 22);
// Turn on LED2 if it is off
// (ANDing to ensure we only affect the LED output)
LPC_GPIO0->FIOSET = ((~ledstate) & (1 << 22));
}

int main(void) {

// TODO: insert code here

// Enter an infinite loop, just incrementing a counter
led2_init();
led2_on();
while(1) {
led2_invert ();
}
return 0 ;
}


This was taken from CMIS2_timers example. How would I configure this to use an external oscillator of 20MHz using the PLL settings/registers. I looked at the datasheet and it is a bit unclear to me. Also, which pin is P0_22 is that pin 56, P0[22]?
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Jul 01 15:36:40 MST 2013

Quote: micro9000
Could the clock settings affect programming? I know that it would affect the speed of an LED blinking if not properly configured, but could this cause more of a problem?



If clock settings are not valid, your code is not running at all. A new (empty) chip is switching in ISP mode with internal clock (IRC), so an empty chip is not causing clock problems.


Quote: micro9000
You said you a ISP 10K pullup resistor. Do you mean from the 3v3 pin coming from the LPC-Link 2?



Yes, that's the same procedure as with your Reset pullup.
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micro9000 on Mon Jul 01 15:29:03 MST 2013
Could the clock settings affect programming? I know that it would affect the speed of an LED blinking if not properly configured, but could this cause more of a problem in terms of programming?

In addition, here are my connections for the LPC-Link 2:

[IMG]http://i188.photobucket.com/albums/z265/fac7orx/armcortexlpclinkconnections_zps26d64bf8.jpg[/IM...

You said you a ISP 10K pullup resistor. Do you mean from the 3v3 pin coming from the LPC-Link 2?
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Jul 01 15:12:01 MST 2013

Quote: micro9000
Is the orientation correct (is that pin 1 correct)?

Yes.
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micro9000 on Mon Jul 01 15:07:56 MST 2013
Here is the setup I am using:

[IMG]http://i188.photobucket.com/albums/z265/fac7orx/connectionsARM1764_zpsa317f76b.jpg[/IMG]

Is the orientation correct (is that pin 1 correct)?
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Jul 01 14:58:07 MST 2013

Quote: micro9000
Thank you for the reply however, from your experience could you guess why this is happening. Should I be using JTAG connections instead of SWD?

Here are my connections to the uC:
LPC1764 <----> LPC Link 2
3<---->2
5<---->3
17<---->6
each VSS pin <----> 8
each VDD pin <----> 1

I am using a 20MHz external resonator connected to pins 22 and 23. I also have a 10K pullup going to the reset pin as well. I have 100nF caps between each VDD and VSS connection as well.




If we are talking about LPC-Link2-J6 that's correct.

I would suggest to add an ISP pullup (10k) and increase the Reset pullup to 22k.

Sounds like a hardware problem.

Note: If you are using LPCXpresso samples you should use 12MHz. Otherwise Standard CMSIS settings don't generate a valid clock setting.
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micro9000 on Mon Jul 01 14:42:44 MST 2013
Thank you for the reply however, from your experience could you guess why this is happening. Should I be using JTAG connections instead of SWD?

Here are my connections to the uC:
LPC1764 <----> LPC Link 2
3<---->2
5<---->3
17<---->6
each VSS pin <----> 8
each VDD pin <----> 1

I am using a 20MHz external resonator connected to pins 22 and 23. I also have a 10K pullup going to the reset pin as well. I have 100nF caps between each VDD and VSS connection as well.
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Jul 01 14:30:29 MST 2013

Quote: micro9000
... is manually browsing and selecting the file within the debug folder okay?



Of course, It's a Flash GUI. Select a file and flash it.


Quote: micro9000
Also, when I do this and click "OK," I get a window that pops up and says:

"02: Failed on connect: Ee(80). Hardware Device not found"

Does this mean that the connections I have made are incorrect?



Yes, wrong wiring.
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micro9000 on Mon Jul 01 14:19:49 MST 2013
I see that you can browse to a ".axf" file which is located within the debug folder of the project directory. So, if there isn't an image immediately detected, is manually browsing and selecting the file within the debug folder okay?

Also, when I do this and click "OK," I get a window that pops up and says:

"02: Failed on connect: Ee(80). Hardware Device not found"

Does this mean that the connections I have made are incorrect?
0 Kudos

811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Jul 01 14:13:42 MST 2013

Quote: micro9000
"Image File " not found."

What does this error message indicate?



No image file :)

Either you didn't build an .axf file or your path is wrong.
0 Kudos