Hello,
i’m new in processor programing and i cant find solution in internet to my problem so far,
here is my problem:
As i wrote in the topic i use lpc2129(or I can get 2103 alternatively) i have usbscarab2 jtag device
due to the major problems using openocd i decided to use crossworks(evaluation) for debugging.
i configured my target as said in document:
http://www.kristech.eu/download/usbscarab2_UM_EN.pdf
i get first available example:
/* *********************************************************
Function declarations
********************************************************* */
void Initialize(void);
void feed(void);
void IRQ_Routine (void) __attribute__ ((interrupt("IRQ")));
void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
void SWI_Routine (void) __attribute__ ((interrupt("SWI")));
void UNDEF_Routine (void) __attribute__ ((interrupt("UNDEF")));
/**********************************************************
Header files
**********************************************************/
#include "lpc214x.h"
#define LED1 (1<<12)
/**********************************************************
Global Variables
**********************************************************/
int q; // global uninitialized variable
int r; // global uninitialized variable
int s; // global uninitialized variable
short h = 2; // global initialized variable
short i = 3; // global initialized variable
char j = 6; // global initialized variable
/**********************************************************
MAIN
**********************************************************/
int main (void) {
long j; // loop counter (stack variable)
static int a,b,c; // static uninitialized variables
static char d; // static uninitialized variables
static int w = 1; // static initialized variable
static long x = 5; // static initialized variable
static char y = 0x04; // static initialized variable
static int z = 7; // static initialized variable
const char *pText = "The Rain in Spain";
// Initialize the system
Initialize();
// set io pins for led P0.10
IODIR0 |= LED1; // pin P0.12 is an output, everything else is input after reset
IOSET0 = LED1; // led off
IOCLR0 = LED1; // led on
// endless loop to toggle the red LED P0.12
while (1) {
for (j = 0; j < 5000000; j++ ); // wait 500 msec
IOSET0 = LED1; // led off
for (j = 0; j < 5000000; j++ ); // wait 500 msec
IOCLR0 = LED1; // led on
}
}
/**********************************************************
Initialize
**********************************************************/
#define PLOCK 0x400
void Initialize(void) {
// Setting the Phased Lock Loop (PLL)
// ----------------------------------
//
// Olimex LPC-P2129 has a 14.7456 mhz crystal
//
// We'd like the LPC2129 to run at 53.2368 mhz (has to be an even multiple of crystal)
//
// According to the Philips LPC2129 manual: M = cclk / Fosc
// where: M = PLL multiplier (bits 0-4 of PLLCFG)
// cclk = 53,236,800 hz
// Fosc = 14,745,600 hz
//
// Solving: M = 53,236,800 / 14,745,600 = 3.6103515625 = 4 (round up)
//
// Note: M - 1 must be entered into bits 0-4 of PLLCFG (assign 3 to these bits)
//
// DAF: Need to recalculate the cclk value using the rounded M.
// cclk = Fosc * M = 14,745,600 * 4 = 58,982,400 (nearly 60Mhz)
//
// The Current Controlled Oscilator (CCO) must operate in the range 156 mhz to 320 mhz
//
// According to the Philips LPC2129 manual: Fcco = cclk * 2 * P where: Fcco = CCO frequency
// cclk = 53236800 hz
// P = PLL divisor (bits 5-6 of PLLCFG)
//
// Solving: Fcco = 58,982,400 * 2 * P
// P = 2 (trial value)
// Fcco = 58,982,400 * 2 * 2
// Fcc0 = 235,929,600 hz (good choice for P since it's within the 156 mhz to 320 mhz range)
//
// From Table 23 (page 77) of Philips LPC2129 manual P = 2, PLLCFG bits 5-6 = 1 (assign 1 to these bits)
//
// Finally: PLLCFG = 0 01 00011 = 0x23
//
// Final note: to load PLLCFG register, we must use the 0xAA followed 0x55 write sequence to the PLLFEED register
// this is done in the short function feed() below
//
// Setting Multiplier and Divider values
PLLCFG=0x23;
feed();
// Enabling the PLL */
PLLCON=0x1;
feed();
// Wait for the PLL to lock to set frequency
while(!(PLLSTAT & PLOCK)) ;
// Connect the PLL as the clock source
PLLCON=0x3;
feed();
// Enabling MAM and setting number of clocks used for Flash memory fetch (4 cclks in this case)
MAMCR=0x0; //Must set MAMCR to 0 before setting MAMTIM page 94, LPC2129 manaul.
MAMTIM=0x4; //Set MAM fetch to 4 cycles.. 3 may work.
MAMCR=0x2; //Now se tthe MAMCR to 2 to fully enable MAM to speed up execution.
// Setting peripheral Clock (pclk) to System Clock (cclk) / 4
VPBDIV=0x0;
}
void feed(void)
{
PLLFEED=0xAA;
PLLFEED=0x55;
}
/* Stubs for various interrupts (may be replaced later) */
/* ---------------------------------------------------- */
void IRQ_Routine (void) {
while (1) ;
}
void FIQ_Routine (void) {
while (1) ;
}
void SWI_Routine (void) {
while (1) ;
}
void UNDEF_Routine (void) {
while (1) ;
}
i created project like in crossworks tutorial and copied c code from example,
building goes very well but debugging shows following message:
“cannot open …\loader.elf”
sometimes with diffrent example i get:
“cannot halt after reset”
what does it mean?
i’d like to debug either from ram or flash, anything that works
thank you for any help