Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Interrupt in LPC22XX

Interrupt in LPC22XX

2006-05-10 by poland459

Hi am new to this forum.I am using "free" KEIL evalution software as 
my IDE to work on LPCE2214 OLIMEX board. Am able to work on TIMER and 
serial port in "polling" mode. But when I enable ISR functions using 
VIC,my program in not jumping to ISR.but in debug mode i could see 
the jump to ISR. also I have DefaultISR in my code.here am attaching 
my code with this mail.
// This program is created for LPC-E2214 board
#include "lpc22xx.h"

#define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
#define PLOCK 0x400 //in MHz


void Initialize(void);
void feed(void);
void UART0Initialize(unsigned int baud);
void UART0WriteChar(unsigned char ch0);
unsigned char UART0ReadChar(void);
unsigned char UART0ReadChar_nostop(void);
unsigned int processorClockFrequency(void);
unsigned int peripheralClockFrequency(void);

void tc0(void)__irq;
static void DefDummyInterrupt(void)__irq;

void init_timer(void);
void InitVIC(void);

long volatile timeval;

void wait (void) /* wait function */
{
unsigned long i;
i = timeval;
while ((i + 10) != timeval); /* wait 100ms */
}



int main()
{
/**** VARIABLES ****/
unsigned char ch0 = 0x0;
unsigned char ch1 = 0x0;
long i=0;

/**** INITIALIZATION ****/
// Frequency initialization
Initialize();
// UART initialization
UART0Initialize(9600);

init_timer();
InitVIC();


while(1)
{

UART0WriteChar('3');
wait();

UART0WriteChar('2');
wait();
}

}


void Initialize(void)
{

// 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=0x2;
MAMTIM=0x4;

// Setting peripheral Clock (pclk) to System Clock (cclk)
VPBDIV=0x1;

}


void feed(void)
{
PLLFEED=0xAA;
PLLFEED=0x55;
}

/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) {
T0MR0 = 149999; // 10mSec = 150000-1 counts
T0MCR = 3; // Interrupt and Reset on MR0
T0TCR = 1; // Timer0 Enable
VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0 Enable
}

/* Timer0 Compare-Match Interrupt Handler (ISR) */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
void tc0 (void) __irq
{
++timeval;
T0IR = 1; // Clear interrupt flag
VICVectAddr = 0; // Acknowledge Interrupt
}
void DefDummyInterrupt(void)__irq
{
;
}
void InitVIC()
{
VICDefVectAddr = (unsigned long)DefDummyInterrupt;
}


/**** UART0 ****/
void UART0Initialize(unsigned int baud)
{
unsigned int divisor = peripheralClockFrequency() / (16 * baud);

U0LCR = 0x83;


//devisor
U0DLL = divisor & 0xFF;
U0DLM = (divisor >> 8) & 0xFF;
U0LCR &= ~0x80;

//set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
PINSEL0 = PINSEL0 & ~0xF | 0x5;
}

void UART0WriteChar(unsigned char ch0)
{
//when U0LSR_bit.THRE is 0 - U0THR contains valid data.
while ((U0LSR && 0x20) == 0);
U0THR = ch0;
}

unsigned char UART0ReadChar(void)
{
//when U0LSR_bit.DR is 1 - U0RBR contains valid data
while ((U0LSR && 0x01) == 0);
return U0RBR;
}
unsigned int processorClockFrequency(void)
{
//return real processor clock speed
return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF) + 
1 : 1);
}

unsigned int peripheralClockFrequency(void)
{
//VPBDIV - determines the relationship between the processor clock 
(cclk)
//and the clock used by peripheral devices (pclk).
unsigned int divider;
switch (VPBDIV & 3)
{
case 0: divider = 4; break;
case 1: divider = 1; break;
case 2: divider = 2; break;
}
return processorClockFrequency() / divider;
}

Please look into this and It would be a great help for me as i have 
been trying for it from past 2 weeks.
I think, abviously iam missing some things. I did not changed any 
things in startup.s file.I will post the start up code if any body 
wanted to look in
please guide me.appreciate your help.

Thanks

Re: Interrupt in LPC22XX

2006-05-10 by fordp2002

Pop this code in and call enableIRQ in main :-

static inline unsigned asm_get_cpsr(void)
{
  unsigned long retval;
  asm volatile (" mrs  %0, cpsr" : "=r" (retval) : /* no inputs */  );
  return retval;
}

static inline void asm_set_cpsr(unsigned val)
{
  asm volatile (" msr  cpsr, %0" : /* no outputs */ : "r" (val)  );
}

unsigned enableIRQ(void)
{
  unsigned _cpsr;

  _cpsr = asm_get_cpsr();
  asm_set_cpsr(_cpsr & ~IRQ_MASK);
  return _cpsr;
}

I got it from the WinARM site a good place for examples.

You may have other problems too, I did not read your code in detail.

Let us know how you get on ;)

FordP


Good
--- In lpc2000@yahoogroups.com, "poland459" <poland459@...> wrote:
Show quoted textHide quoted text
>
> Hi am new to this forum.I am using "free" KEIL evalution software as 
> my IDE to work on LPCE2214 OLIMEX board. Am able to work on TIMER and 
> serial port in "polling" mode. But when I enable ISR functions using 
> VIC,my program in not jumping to ISR.but in debug mode i could see 
> the jump to ISR. also I have DefaultISR in my code.here am attaching 
> my code with this mail.
> // This program is created for LPC-E2214 board
> #include "lpc22xx.h"
> 
> #define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
> #define PLOCK 0x400 //in MHz
> 
> 
> void Initialize(void);
> void feed(void);
> void UART0Initialize(unsigned int baud);
> void UART0WriteChar(unsigned char ch0);
> unsigned char UART0ReadChar(void);
> unsigned char UART0ReadChar_nostop(void);
> unsigned int processorClockFrequency(void);
> unsigned int peripheralClockFrequency(void);
> 
> void tc0(void)__irq;
> static void DefDummyInterrupt(void)__irq;
> 
> void init_timer(void);
> void InitVIC(void);
> 
> long volatile timeval;
> 
> void wait (void) /* wait function */
> {
> unsigned long i;
> i = timeval;
> while ((i + 10) != timeval); /* wait 100ms */
> }
> 
> 
> 
> int main()
> {
> /**** VARIABLES ****/
> unsigned char ch0 = 0x0;
> unsigned char ch1 = 0x0;
> long i=0;
> 
> /**** INITIALIZATION ****/
> // Frequency initialization
> Initialize();
> // UART initialization
> UART0Initialize(9600);
> 
> init_timer();
> InitVIC();
> 
> 
> while(1)
> {
> 
> UART0WriteChar('3');
> wait();
> 
> UART0WriteChar('2');
> wait();
> }
> 
> }
> 
> 
> void Initialize(void)
> {
> 
> // 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=0x2;
> MAMTIM=0x4;
> 
> // Setting peripheral Clock (pclk) to System Clock (cclk)
> VPBDIV=0x1;
> 
> }
> 
> 
> void feed(void)
> {
> PLLFEED=0xAA;
> PLLFEED=0x55;
> }
> 
> /* Setup the Timer Counter 0 Interrupt */
> void init_timer (void) {
> T0MR0 = 149999; // 10mSec = 150000-1 counts
> T0MCR = 3; // Interrupt and Reset on MR0
> T0TCR = 1; // Timer0 Enable
> VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
> VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
> VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0 Enable
> }
> 
> /* Timer0 Compare-Match Interrupt Handler (ISR) */
> /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
> /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
> void tc0 (void) __irq
> {
> ++timeval;
> T0IR = 1; // Clear interrupt flag
> VICVectAddr = 0; // Acknowledge Interrupt
> }
> void DefDummyInterrupt(void)__irq
> {
> ;
> }
> void InitVIC()
> {
> VICDefVectAddr = (unsigned long)DefDummyInterrupt;
> }
> 
> 
> /**** UART0 ****/
> void UART0Initialize(unsigned int baud)
> {
> unsigned int divisor = peripheralClockFrequency() / (16 * baud);
> 
> U0LCR = 0x83;
> 
> 
> //devisor
> U0DLL = divisor & 0xFF;
> U0DLM = (divisor >> 8) & 0xFF;
> U0LCR &= ~0x80;
> 
> //set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
> PINSEL0 = PINSEL0 & ~0xF | 0x5;
> }
> 
> void UART0WriteChar(unsigned char ch0)
> {
> //when U0LSR_bit.THRE is 0 - U0THR contains valid data.
> while ((U0LSR && 0x20) == 0);
> U0THR = ch0;
> }
> 
> unsigned char UART0ReadChar(void)
> {
> //when U0LSR_bit.DR is 1 - U0RBR contains valid data
> while ((U0LSR && 0x01) == 0);
> return U0RBR;
> }
> unsigned int processorClockFrequency(void)
> {
> //return real processor clock speed
> return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF) + 
> 1 : 1);
> }
> 
> unsigned int peripheralClockFrequency(void)
> {
> //VPBDIV - determines the relationship between the processor clock 
> (cclk)
> //and the clock used by peripheral devices (pclk).
> unsigned int divider;
> switch (VPBDIV & 3)
> {
> case 0: divider = 4; break;
> case 1: divider = 1; break;
> case 2: divider = 2; break;
> }
> return processorClockFrequency() / divider;
> }
> 
> Please look into this and It would be a great help for me as i have 
> been trying for it from past 2 weeks.
> I think, abviously iam missing some things. I did not changed any 
> things in startup.s file.I will post the start up code if any body 
> wanted to look in
> please guide me.appreciate your help.
> 
> Thanks
>

RE: [lpc2000] Interrupt in LPC22XX

2006-05-10 by Andrew Berney

Errrm I've not looked at the data sheets for that particular part, but it
doesn't appear that you're turning on the serial IRQ...
on the 2129 I'm currently working on it'd be something like:

  VICVectCntl1 = 0x00000026; // IRQ 6 enabled - the IRQ for UART0
  VICVectAddr1 = (unsigned)UART0_Irq; // Function to run as IRQ
  VICIntEnable |= 0x00000040; // flick its bit on to show we want this IRQ
firing...

likewise for UART1:

  VICVectCntl2 = 0x00000027; // IRQ 7 enabled
  VICVectAddr2 = (unsigned)UART1_Irq;
  VICIntEnable |= 0x00000080;

I imagine it's probably the same for yours...

One other thing to note is that your watchdog feed is currently not an
atomic instruction - ie if you get interrupted between the two writes you're
doing the watchdog will trip... (better to disable the IRQ's when kicking
the dog then turn them back on). Personally I simply use one of the on chip
timers to give me an interrupt every so often and then kick the watchdog
inside it's IRQ handler...

Andy
Show quoted textHide quoted text
-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of poland459
Sent: 10 May 2006 05:59
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Interrupt in LPC22XX


Hi am new to this forum.I am using "free" KEIL evalution software as
my IDE to work on LPCE2214 OLIMEX board. Am able to work on TIMER and
serial port in "polling" mode. But when I enable ISR functions using
VIC,my program in not jumping to ISR.but in debug mode i could see
the jump to ISR. also I have DefaultISR in my code.here am attaching
my code with this mail.
// This program is created for LPC-E2214 board
#include "lpc22xx.h"

#define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
#define PLOCK 0x400 //in MHz


void Initialize(void);
void feed(void);
void UART0Initialize(unsigned int baud);
void UART0WriteChar(unsigned char ch0);
unsigned char UART0ReadChar(void);
unsigned char UART0ReadChar_nostop(void);
unsigned int processorClockFrequency(void);
unsigned int peripheralClockFrequency(void);

void tc0(void)__irq;
static void DefDummyInterrupt(void)__irq;

void init_timer(void);
void InitVIC(void);

long volatile timeval;

void wait (void) /* wait function */
{
unsigned long i;
i = timeval;
while ((i + 10) != timeval); /* wait 100ms */
}



int main()
{
/**** VARIABLES ****/
unsigned char ch0 = 0x0;
unsigned char ch1 = 0x0;
long i=0;

/**** INITIALIZATION ****/
// Frequency initialization
Initialize();
// UART initialization
UART0Initialize(9600);

init_timer();
InitVIC();


while(1)
{

UART0WriteChar('3');
wait();

UART0WriteChar('2');
wait();
}

}


void Initialize(void)
{

// 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=0x2;
MAMTIM=0x4;

// Setting peripheral Clock (pclk) to System Clock (cclk)
VPBDIV=0x1;

}


void feed(void)
{
PLLFEED=0xAA;
PLLFEED=0x55;
}

/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) {
T0MR0 = 149999; // 10mSec = 150000-1 counts
T0MCR = 3; // Interrupt and Reset on MR0
T0TCR = 1; // Timer0 Enable
VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0 Enable
}

/* Timer0 Compare-Match Interrupt Handler (ISR) */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
void tc0 (void) __irq
{
++timeval;
T0IR = 1; // Clear interrupt flag
VICVectAddr = 0; // Acknowledge Interrupt
}
void DefDummyInterrupt(void)__irq
{
;
}
void InitVIC()
{
VICDefVectAddr = (unsigned long)DefDummyInterrupt;
}


/**** UART0 ****/
void UART0Initialize(unsigned int baud)
{
unsigned int divisor = peripheralClockFrequency() / (16 * baud);

U0LCR = 0x83;


//devisor
U0DLL = divisor & 0xFF;
U0DLM = (divisor >> 8) & 0xFF;
U0LCR &= ~0x80;

//set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
PINSEL0 = PINSEL0 & ~0xF | 0x5;
}

void UART0WriteChar(unsigned char ch0)
{
//when U0LSR_bit.THRE is 0 - U0THR contains valid data.
while ((U0LSR && 0x20) == 0);
U0THR = ch0;
}

unsigned char UART0ReadChar(void)
{
//when U0LSR_bit.DR is 1 - U0RBR contains valid data
while ((U0LSR && 0x01) == 0);
return U0RBR;
}
unsigned int processorClockFrequency(void)
{
//return real processor clock speed
return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF) +
1 : 1);
}

unsigned int peripheralClockFrequency(void)
{
//VPBDIV - determines the relationship between the processor clock
(cclk)
//and the clock used by peripheral devices (pclk).
unsigned int divider;
switch (VPBDIV & 3)
{
case 0: divider = 4; break;
case 1: divider = 1; break;
case 2: divider = 2; break;
}
return processorClockFrequency() / divider;
}

Please look into this and It would be a great help for me as i have
been trying for it from past 2 weeks.
I think, abviously iam missing some things. I did not changed any
things in startup.s file.I will post the start up code if any body
wanted to look in
please guide me.appreciate your help.

Thanks







Yahoo! Groups Links

RE: [lpc2000] Interrupt in LPC22XX

2006-05-10 by Andrew Berney

Actually, just checked and you'll also need:

  U0IER   = 0x00000001;     //enable rx data available interrupt

as well...eg:

  VPBDIV  = 0x00000001;		//Set PClk to 60Mhz

  // UART0
  U0LCR   = 0x00000083;     // 8 bits, no Parity, 1 Stop bit
  U0DLL   = 0x000000C2;     // 19,200 Baud Rate @ 60MHz VPB Clock
  U0DLM   = 0x00000000;
  U0LCR   = 0x00000003;     // DLAB = 0
  U0IER   = 0x00000001;     //enable rx data available interrupt

  VICVectCntl1 = 0x00000026; // IRQ 6 enabled
  VICVectAddr1 = (unsigned)UART0_Irq;
  VICIntEnable |= 0x00000040;

  U0FCR   = 0x00000001;		//Enable FIFO & trigger level to 1 byte

Hope that helps...

Andy
Show quoted textHide quoted text
-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of Andrew Berney
Sent: 10 May 2006 09:42
To: lpc2000@yahoogroups.com
Subject: RE: [lpc2000] Interrupt in LPC22XX


Errrm I've not looked at the data sheets for that particular part, but it
doesn't appear that you're turning on the serial IRQ...
on the 2129 I'm currently working on it'd be something like:

  VICVectCntl1 = 0x00000026; // IRQ 6 enabled - the IRQ for UART0
  VICVectAddr1 = (unsigned)UART0_Irq; // Function to run as IRQ
  VICIntEnable |= 0x00000040; // flick its bit on to show we want this IRQ
firing...

likewise for UART1:

  VICVectCntl2 = 0x00000027; // IRQ 7 enabled
  VICVectAddr2 = (unsigned)UART1_Irq;
  VICIntEnable |= 0x00000080;

I imagine it's probably the same for yours...

One other thing to note is that your watchdog feed is currently not an
atomic instruction - ie if you get interrupted between the two writes you're
doing the watchdog will trip... (better to disable the IRQ's when kicking
the dog then turn them back on). Personally I simply use one of the on chip
timers to give me an interrupt every so often and then kick the watchdog
inside it's IRQ handler...

Andy


-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of poland459
Sent: 10 May 2006 05:59
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Interrupt in LPC22XX


Hi am new to this forum.I am using "free" KEIL evalution software as
my IDE to work on LPCE2214 OLIMEX board. Am able to work on TIMER and
serial port in "polling" mode. But when I enable ISR functions using
VIC,my program in not jumping to ISR.but in debug mode i could see
the jump to ISR. also I have DefaultISR in my code.here am attaching
my code with this mail.
// This program is created for LPC-E2214 board
#include "lpc22xx.h"

#define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
#define PLOCK 0x400 //in MHz


void Initialize(void);
void feed(void);
void UART0Initialize(unsigned int baud);
void UART0WriteChar(unsigned char ch0);
unsigned char UART0ReadChar(void);
unsigned char UART0ReadChar_nostop(void);
unsigned int processorClockFrequency(void);
unsigned int peripheralClockFrequency(void);

void tc0(void)__irq;
static void DefDummyInterrupt(void)__irq;

void init_timer(void);
void InitVIC(void);

long volatile timeval;

void wait (void) /* wait function */
{
unsigned long i;
i = timeval;
while ((i + 10) != timeval); /* wait 100ms */
}



int main()
{
/**** VARIABLES ****/
unsigned char ch0 = 0x0;
unsigned char ch1 = 0x0;
long i=0;

/**** INITIALIZATION ****/
// Frequency initialization
Initialize();
// UART initialization
UART0Initialize(9600);

init_timer();
InitVIC();


while(1)
{

UART0WriteChar('3');
wait();

UART0WriteChar('2');
wait();
}

}


void Initialize(void)
{

// 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=0x2;
MAMTIM=0x4;

// Setting peripheral Clock (pclk) to System Clock (cclk)
VPBDIV=0x1;

}


void feed(void)
{
PLLFEED=0xAA;
PLLFEED=0x55;
}

/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) {
T0MR0 = 149999; // 10mSec = 150000-1 counts
T0MCR = 3; // Interrupt and Reset on MR0
T0TCR = 1; // Timer0 Enable
VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0 Enable
}

/* Timer0 Compare-Match Interrupt Handler (ISR) */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
void tc0 (void) __irq
{
++timeval;
T0IR = 1; // Clear interrupt flag
VICVectAddr = 0; // Acknowledge Interrupt
}
void DefDummyInterrupt(void)__irq
{
;
}
void InitVIC()
{
VICDefVectAddr = (unsigned long)DefDummyInterrupt;
}


/**** UART0 ****/
void UART0Initialize(unsigned int baud)
{
unsigned int divisor = peripheralClockFrequency() / (16 * baud);

U0LCR = 0x83;


//devisor
U0DLL = divisor & 0xFF;
U0DLM = (divisor >> 8) & 0xFF;
U0LCR &= ~0x80;

//set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
PINSEL0 = PINSEL0 & ~0xF | 0x5;
}

void UART0WriteChar(unsigned char ch0)
{
//when U0LSR_bit.THRE is 0 - U0THR contains valid data.
while ((U0LSR && 0x20) == 0);
U0THR = ch0;
}

unsigned char UART0ReadChar(void)
{
//when U0LSR_bit.DR is 1 - U0RBR contains valid data
while ((U0LSR && 0x01) == 0);
return U0RBR;
}
unsigned int processorClockFrequency(void)
{
//return real processor clock speed
return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF) +
1 : 1);
}

unsigned int peripheralClockFrequency(void)
{
//VPBDIV - determines the relationship between the processor clock
(cclk)
//and the clock used by peripheral devices (pclk).
unsigned int divider;
switch (VPBDIV & 3)
{
case 0: divider = 4; break;
case 1: divider = 1; break;
case 2: divider = 2; break;
}
return processorClockFrequency() / divider;
}

Please look into this and It would be a great help for me as i have
been trying for it from past 2 weeks.
I think, abviously iam missing some things. I did not changed any
things in startup.s file.I will post the start up code if any body
wanted to look in
please guide me.appreciate your help.

Thanks







Yahoo! Groups Links











Yahoo! Groups Links

Re: Interrupt in LPC22XX

2006-05-10 by brendanmurphy37

--- In lpc2000@yahoogroups.com, "Andrew Berney" <amb@...> wrote:
> Personally I simply use one of the on chip
> timers to give me an interrupt every so often and then kick the 
watchdog
> inside it's IRQ handler...
> 
> Andy

Andy,

Can you explain more about how you're using the watchdog, as what you 
say sounds a bit strange if you take it at face value?

One of the functions of a watchdog is to reset a system to a known 
state to recover from (previously unknown) software (or indeed 
hardware induced) errors. If the software error involves entering an 
infinite loop then a timer interrupt that just feeds the watchdog 
won't recover the system: the watchdog will never expire.

No doubt you're doing something else: for example in the timer 
interrupt you could check one or more status fields that are 
continuously updated by parts of the application and only feed the 
watchdog if everything is looking good.

Also, you still need to ensure interrupts are disabled for the feed 
sequence, unless you don't allow nested interrupts.

Just in case anyone reading your post gets the wrong idea it might be 
worth clarifying these points.

Brendan.

RE: [lpc2000] Re: Interrupt in LPC22XX

2006-05-10 by Andrew Berney

Sorry yes, to clarify we do exactly as you said - the IRQ for the timer
checks the state of all the registered subsystems (which for the current
project are quite limited) - assuming they're all ok (or simply degraded but
still running well enough to allow continued operation) it kicks the
watchdog - and we don't allow nested IRQs although both FIQ and IRQ are
disabled anyway for the feed sequence.

Andy
Show quoted textHide quoted text
-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of brendanmurphy37
Sent: 10 May 2006 10:22
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Re: Interrupt in LPC22XX


--- In lpc2000@yahoogroups.com, "Andrew Berney" <amb@...> wrote:
> Personally I simply use one of the on chip
> timers to give me an interrupt every so often and then kick the
watchdog
> inside it's IRQ handler...
>
> Andy

Andy,

Can you explain more about how you're using the watchdog, as what you
say sounds a bit strange if you take it at face value?

One of the functions of a watchdog is to reset a system to a known
state to recover from (previously unknown) software (or indeed
hardware induced) errors. If the software error involves entering an
infinite loop then a timer interrupt that just feeds the watchdog
won't recover the system: the watchdog will never expire.

No doubt you're doing something else: for example in the timer
interrupt you could check one or more status fields that are
continuously updated by parts of the application and only feed the
watchdog if everything is looking good.

Also, you still need to ensure interrupts are disabled for the feed
sequence, unless you don't allow nested interrupts.

Just in case anyone reading your post gets the wrong idea it might be
worth clarifying these points.

Brendan.










Yahoo! Groups Links

Re: Interrupt in LPC22XX

2006-05-10 by poland459

Thanks for your reply..I have added the asm code and called enableIRQ 
after the timer is enabled.. But the program is not jumping to ISR...

I forgot to mention in my first post that, iam using UART0 in polling 
mode and TIMER0 in ISR..(ISR is not triggered even if I use only 
TIMER0 in ISR).

here is the asm code..

static __inline unsigned long asm_get_cpsr(void) __arm
{
   unsigned long retval;
  __asm { mrs retval, CPSR }; 
   return retval;
}

static __inline void asm_set_cpsr(unsigned long value)  __arm{
  value = value;              // avoid warning: unused parameter
  __asm { msr CPSR_c, R0 };   // value passed in R0
}

unsigned long enableIRQ(void)
{
   unsigned long _cpsr;

   _cpsr = asm_get_cpsr();
   asm_set_cpsr(_cpsr & ~IRQ_MASK);
   return _cpsr;
}

Thank you.

--- In lpc2000@yahoogroups.com, "fordp2002" <SimonEllwood@...> wrote:
 
> I got it from the WinARM site a good place for examples.
> 
> You may have other problems too, I did not read your code in detail.
> 
> Let us know how you get on ;)
> 
> FordP
> 
> 
> Good
> --- In lpc2000@yahoogroups.com, "poland459" <poland459@> wrote:
> >
> > Hi am new to this forum.I am using "free" KEIL evalution software 
as 
> > my IDE to work on LPCE2214 OLIMEX board. Am able to work on TIMER 
and 
> > serial port in "polling" mode. But when I enable ISR functions 
using 
> > VIC,my program in not jumping to ISR.but in debug mode i could 
see 
> > the jump to ISR. also I have DefaultISR in my code.here am 
attaching 
> > my code with this mail.
> > // This program is created for LPC-E2214 board
> > #include "lpc22xx.h"
> > 
> > #define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
> > #define PLOCK 0x400 //in MHz
> > 
> > 
> > void Initialize(void);
> > void feed(void);
> > void UART0Initialize(unsigned int baud);
> > void UART0WriteChar(unsigned char ch0);
> > unsigned char UART0ReadChar(void);
> > unsigned char UART0ReadChar_nostop(void);
> > unsigned int processorClockFrequency(void);
> > unsigned int peripheralClockFrequency(void);
> > 
> > void tc0(void)__irq;
> > static void DefDummyInterrupt(void)__irq;
> > 
> > void init_timer(void);
> > void InitVIC(void);
> > 
> > long volatile timeval;
> > 
> > void wait (void) /* wait function */
> > {
> > unsigned long i;
> > i = timeval;
> > while ((i + 10) != timeval); /* wait 100ms */
> > }
> > 
> > 
> > 
> > int main()
> > {
> > /**** VARIABLES ****/
> > unsigned char ch0 = 0x0;
> > unsigned char ch1 = 0x0;
> > long i=0;
> > 
> > /**** INITIALIZATION ****/
> > // Frequency initialization
> > Initialize();
> > // UART initialization
> > UART0Initialize(9600);
> > 
> > init_timer();
> > InitVIC();
> > 
> > 
> > while(1)
> > {
> > 
> > UART0WriteChar('3');
> > wait();
> > 
> > UART0WriteChar('2');
> > wait();
> > }
> > 
> > }
> > 
> > 
> > void Initialize(void)
> > {
> > 
> > // 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=0x2;
> > MAMTIM=0x4;
> > 
> > // Setting peripheral Clock (pclk) to System Clock (cclk)
> > VPBDIV=0x1;
> > 
> > }
> > 
> > 
> > void feed(void)
> > {
> > PLLFEED=0xAA;
> > PLLFEED=0x55;
> > }
> > 
> > /* Setup the Timer Counter 0 Interrupt */
> > void init_timer (void) {
> > T0MR0 = 149999; // 10mSec = 150000-1 counts
> > T0MCR = 3; // Interrupt and Reset on MR0
> > T0TCR = 1; // Timer0 Enable
> > VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
> > VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
> > VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0 
Enable
> > }
> > 
> > /* Timer0 Compare-Match Interrupt Handler (ISR) */
> > /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU 
Clock */
> > /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU 
Clock */
> > void tc0 (void) __irq
> > {
> > ++timeval;
> > T0IR = 1; // Clear interrupt flag
> > VICVectAddr = 0; // Acknowledge Interrupt
> > }
> > void DefDummyInterrupt(void)__irq
> > {
> > ;
> > }
> > void InitVIC()
> > {
> > VICDefVectAddr = (unsigned long)DefDummyInterrupt;
> > }
> > 
> > 
> > /**** UART0 ****/
> > void UART0Initialize(unsigned int baud)
> > {
> > unsigned int divisor = peripheralClockFrequency() / (16 * baud);
> > 
> > U0LCR = 0x83;
> > 
> > 
> > //devisor
> > U0DLL = divisor & 0xFF;
> > U0DLM = (divisor >> 8) & 0xFF;
> > U0LCR &= ~0x80;
> > 
> > //set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
> > PINSEL0 = PINSEL0 & ~0xF | 0x5;
> > }
> > 
> > void UART0WriteChar(unsigned char ch0)
> > {
> > //when U0LSR_bit.THRE is 0 - U0THR contains valid data.
> > while ((U0LSR && 0x20) == 0);
> > U0THR = ch0;
> > }
> > 
> > unsigned char UART0ReadChar(void)
> > {
> > //when U0LSR_bit.DR is 1 - U0RBR contains valid data
> > while ((U0LSR && 0x01) == 0);
> > return U0RBR;
> > }
> > unsigned int processorClockFrequency(void)
> > {
> > //return real processor clock speed
> > return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF) 
+ 
> > 1 : 1);
> > }
> > 
> > unsigned int peripheralClockFrequency(void)
> > {
> > //VPBDIV - determines the relationship between the processor 
clock 
> > (cclk)
> > //and the clock used by peripheral devices (pclk).
> > unsigned int divider;
> > switch (VPBDIV & 3)
> > {
> > case 0: divider = 4; break;
> > case 1: divider = 1; break;
> > case 2: divider = 2; break;
> > }
> > return processorClockFrequency() / divider;
> > }
> > 
> > Please look into this and It would be a great help for me as i 
have 
> > been trying for it from past 2 weeks.
> > I think, abviously iam missing some things. I did not changed any 
> > things in startup.s file.I will post the start up code if any 
body 
Show quoted textHide quoted text
> > wanted to look in
> > please guide me.appreciate your help.
> > 
> > Thanks
> >
>

RE: [lpc2000] Re: Interrupt in LPC22XX

2006-05-10 by Andrew Berney

Ok... I spent a little more time and actually read through your code
properly. I'm not actualy quite sure what you're trying to achieve however
there's a few obvious things.

1) are you trying to actually use the watchdog? I can't see any reference to
setting up WDTC or WDMOD so are you sure it's actually switched on?
2) if you are actively using it you don't have any form of kick for it
inside your main while loop (one of the reasons I decouple it to a timer IRQ
that acts as an internal system check to look at running statuses).
3) Can't remember off the top of my head, but don't you also have to reset
the count for the timer when you initialise it?
ie:
	T0PR  = 0x1;      // set the prescaler to the pclk frequency 60MHz
	T0TCR = 0x2;      // reset the counter to 0
	T0MCR = 0x3;      // on match generate an IRQ
	T0MR0 = 0x600000; // count 0x600000 hex cycles per IRQ
	T0TCR = 0x1;      // enable timer

	VICVectCntl0 = 0x24;            // IRQ 4 + Enabled bit
	VICVectAddr0 = (unsigned)T0ISR; // address of IRQ handler
	VICIntEnable |= 0x10;           // Turn on IRQ 4

4) Have you checked the UART parameters to ensure your clock and divisors
etc are giving you the correct baud rate?

Andy
Show quoted textHide quoted text
-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of poland459
Sent: 10 May 2006 11:40
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Re: Interrupt in LPC22XX


Thanks for your reply..I have added the asm code and called enableIRQ
after the timer is enabled.. But the program is not jumping to ISR...

I forgot to mention in my first post that, iam using UART0 in polling
mode and TIMER0 in ISR..(ISR is not triggered even if I use only
TIMER0 in ISR).

here is the asm code..

static __inline unsigned long asm_get_cpsr(void) __arm
{
   unsigned long retval;
  __asm { mrs retval, CPSR };
   return retval;
}

static __inline void asm_set_cpsr(unsigned long value)  __arm{
  value = value;              // avoid warning: unused parameter
  __asm { msr CPSR_c, R0 };   // value passed in R0
}

unsigned long enableIRQ(void)
{
   unsigned long _cpsr;

   _cpsr = asm_get_cpsr();
   asm_set_cpsr(_cpsr & ~IRQ_MASK);
   return _cpsr;
}

Thank you.

--- In lpc2000@yahoogroups.com, "fordp2002" <SimonEllwood@...> wrote:

> I got it from the WinARM site a good place for examples.
>
> You may have other problems too, I did not read your code in detail.
>
> Let us know how you get on ;)
>
> FordP
>
>
> Good
> --- In lpc2000@yahoogroups.com, "poland459" <poland459@> wrote:
> >
> > Hi am new to this forum.I am using "free" KEIL evalution software
as
> > my IDE to work on LPCE2214 OLIMEX board. Am able to work on TIMER
and
> > serial port in "polling" mode. But when I enable ISR functions
using
> > VIC,my program in not jumping to ISR.but in debug mode i could
see
> > the jump to ISR. also I have DefaultISR in my code.here am
attaching
> > my code with this mail.
> > // This program is created for LPC-E2214 board
> > #include "lpc22xx.h"
> >
> > #define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
> > #define PLOCK 0x400 //in MHz
> >
> >
> > void Initialize(void);
> > void feed(void);
> > void UART0Initialize(unsigned int baud);
> > void UART0WriteChar(unsigned char ch0);
> > unsigned char UART0ReadChar(void);
> > unsigned char UART0ReadChar_nostop(void);
> > unsigned int processorClockFrequency(void);
> > unsigned int peripheralClockFrequency(void);
> >
> > void tc0(void)__irq;
> > static void DefDummyInterrupt(void)__irq;
> >
> > void init_timer(void);
> > void InitVIC(void);
> >
> > long volatile timeval;
> >
> > void wait (void) /* wait function */
> > {
> > unsigned long i;
> > i = timeval;
> > while ((i + 10) != timeval); /* wait 100ms */
> > }
> >
> >
> >
> > int main()
> > {
> > /**** VARIABLES ****/
> > unsigned char ch0 = 0x0;
> > unsigned char ch1 = 0x0;
> > long i=0;
> >
> > /**** INITIALIZATION ****/
> > // Frequency initialization
> > Initialize();
> > // UART initialization
> > UART0Initialize(9600);
> >
> > init_timer();
> > InitVIC();
> >
> >
> > while(1)
> > {
> >
> > UART0WriteChar('3');
> > wait();
> >
> > UART0WriteChar('2');
> > wait();
> > }
> >
> > }
> >
> >
> > void Initialize(void)
> > {
> >
> > // 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=0x2;
> > MAMTIM=0x4;
> >
> > // Setting peripheral Clock (pclk) to System Clock (cclk)
> > VPBDIV=0x1;
> >
> > }
> >
> >
> > void feed(void)
> > {
> > PLLFEED=0xAA;
> > PLLFEED=0x55;
> > }
> >
> > /* Setup the Timer Counter 0 Interrupt */
> > void init_timer (void) {
> > T0MR0 = 149999; // 10mSec = 150000-1 counts
> > T0MCR = 3; // Interrupt and Reset on MR0
> > T0TCR = 1; // Timer0 Enable
> > VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
> > VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
> > VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0
Enable
> > }
> >
> > /* Timer0 Compare-Match Interrupt Handler (ISR) */
> > /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU
Clock */
> > /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU
Clock */
> > void tc0 (void) __irq
> > {
> > ++timeval;
> > T0IR = 1; // Clear interrupt flag
> > VICVectAddr = 0; // Acknowledge Interrupt
> > }
> > void DefDummyInterrupt(void)__irq
> > {
> > ;
> > }
> > void InitVIC()
> > {
> > VICDefVectAddr = (unsigned long)DefDummyInterrupt;
> > }
> >
> >
> > /**** UART0 ****/
> > void UART0Initialize(unsigned int baud)
> > {
> > unsigned int divisor = peripheralClockFrequency() / (16 * baud);
> >
> > U0LCR = 0x83;
> >
> >
> > //devisor
> > U0DLL = divisor & 0xFF;
> > U0DLM = (divisor >> 8) & 0xFF;
> > U0LCR &= ~0x80;
> >
> > //set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
> > PINSEL0 = PINSEL0 & ~0xF | 0x5;
> > }
> >
> > void UART0WriteChar(unsigned char ch0)
> > {
> > //when U0LSR_bit.THRE is 0 - U0THR contains valid data.
> > while ((U0LSR && 0x20) == 0);
> > U0THR = ch0;
> > }
> >
> > unsigned char UART0ReadChar(void)
> > {
> > //when U0LSR_bit.DR is 1 - U0RBR contains valid data
> > while ((U0LSR && 0x01) == 0);
> > return U0RBR;
> > }
> > unsigned int processorClockFrequency(void)
> > {
> > //return real processor clock speed
> > return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF)
+
> > 1 : 1);
> > }
> >
> > unsigned int peripheralClockFrequency(void)
> > {
> > //VPBDIV - determines the relationship between the processor
clock
> > (cclk)
> > //and the clock used by peripheral devices (pclk).
> > unsigned int divider;
> > switch (VPBDIV & 3)
> > {
> > case 0: divider = 4; break;
> > case 1: divider = 1; break;
> > case 2: divider = 2; break;
> > }
> > return processorClockFrequency() / divider;
> > }
> >
> > Please look into this and It would be a great help for me as i
have
> > been trying for it from past 2 weeks.
> > I think, abviously iam missing some things. I did not changed any
> > things in startup.s file.I will post the start up code if any
body
> > wanted to look in
> > please guide me.appreciate your help.
> >
> > Thanks
> >
>








Yahoo! Groups Links

Re: Interrupt in LPC22XX

2006-05-10 by poland459

Thanks for your time.
1&2]Am not using watchdog timer. And i didnot touched watch dog 
timer.as am learning this LPC, my aim is to send bytes to 
hyperterminal for every 10ms with a 9600 baud rate.
3]I forgot to reset the counter value.Its noted but its not help ful 
in my problem. Thank you
4]I have checked the UART condtions, everything looks fine. Am able 
to receive bytes before the timer is being initialised.

Thanks again.


--- In lpc2000@yahoogroups.com, "Andrew Berney" <amb@...> wrote:
>
> Ok... I spent a little more time and actually read through your code
> properly. I'm not actualy quite sure what you're trying to achieve 
however
> there's a few obvious things.
> 
> 1) are you trying to actually use the watchdog? I can't see any 
reference to
> setting up WDTC or WDMOD so are you sure it's actually switched on?
> 2) if you are actively using it you don't have any form of kick for 
it
> inside your main while loop (one of the reasons I decouple it to a 
timer IRQ
> that acts as an internal system check to look at running statuses).
> 3) Can't remember off the top of my head, but don't you also have 
to reset
> the count for the timer when you initialise it?
> ie:
> 	T0PR  = 0x1;      // set the prescaler to the pclk frequency 
60MHz
> 	T0TCR = 0x2;      // reset the counter to 0
> 	T0MCR = 0x3;      // on match generate an IRQ
> 	T0MR0 = 0x600000; // count 0x600000 hex cycles per IRQ
> 	T0TCR = 0x1;      // enable timer
> 
> 	VICVectCntl0 = 0x24;            // IRQ 4 + Enabled bit
> 	VICVectAddr0 = (unsigned)T0ISR; // address of IRQ handler
> 	VICIntEnable |= 0x10;           // Turn on IRQ 4
> 
> 4) Have you checked the UART parameters to ensure your clock and 
divisors
> etc are giving you the correct baud rate?
> 
> Andy
> 
> 
> -----Original Message-----
> From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On 
Behalf
> Of poland459
> Sent: 10 May 2006 11:40
> To: lpc2000@yahoogroups.com
> Subject: [lpc2000] Re: Interrupt in LPC22XX
> 
> 
> Thanks for your reply..I have added the asm code and called 
enableIRQ
> after the timer is enabled.. But the program is not jumping to 
ISR...
> 
> I forgot to mention in my first post that, iam using UART0 in 
polling
> mode and TIMER0 in ISR..(ISR is not triggered even if I use only
> TIMER0 in ISR).
> 
> here is the asm code..
> 
> static __inline unsigned long asm_get_cpsr(void) __arm
> {
>    unsigned long retval;
>   __asm { mrs retval, CPSR };
>    return retval;
> }
> 
> static __inline void asm_set_cpsr(unsigned long value)  __arm{
>   value = value;              // avoid warning: unused parameter
>   __asm { msr CPSR_c, R0 };   // value passed in R0
> }
> 
> unsigned long enableIRQ(void)
> {
>    unsigned long _cpsr;
> 
>    _cpsr = asm_get_cpsr();
>    asm_set_cpsr(_cpsr & ~IRQ_MASK);
>    return _cpsr;
> }
> 
> Thank you.
> 
> --- In lpc2000@yahoogroups.com, "fordp2002" <SimonEllwood@> wrote:
> 
> > I got it from the WinARM site a good place for examples.
> >
> > You may have other problems too, I did not read your code in 
detail.
> >
> > Let us know how you get on ;)
> >
> > FordP
> >
> >
> > Good
> > --- In lpc2000@yahoogroups.com, "poland459" <poland459@> wrote:
> > >
> > > Hi am new to this forum.I am using "free" KEIL evalution 
software
> as
> > > my IDE to work on LPCE2214 OLIMEX board. Am able to work on 
TIMER
> and
> > > serial port in "polling" mode. But when I enable ISR functions
> using
> > > VIC,my program in not jumping to ISR.but in debug mode i could
> see
> > > the jump to ISR. also I have DefaultISR in my code.here am
> attaching
> > > my code with this mail.
> > > // This program is created for LPC-E2214 board
> > > #include "lpc22xx.h"
> > >
> > > #define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
> > > #define PLOCK 0x400 //in MHz
> > >
> > >
> > > void Initialize(void);
> > > void feed(void);
> > > void UART0Initialize(unsigned int baud);
> > > void UART0WriteChar(unsigned char ch0);
> > > unsigned char UART0ReadChar(void);
> > > unsigned char UART0ReadChar_nostop(void);
> > > unsigned int processorClockFrequency(void);
> > > unsigned int peripheralClockFrequency(void);
> > >
> > > void tc0(void)__irq;
> > > static void DefDummyInterrupt(void)__irq;
> > >
> > > void init_timer(void);
> > > void InitVIC(void);
> > >
> > > long volatile timeval;
> > >
> > > void wait (void) /* wait function */
> > > {
> > > unsigned long i;
> > > i = timeval;
> > > while ((i + 10) != timeval); /* wait 100ms */
> > > }
> > >
> > >
> > >
> > > int main()
> > > {
> > > /**** VARIABLES ****/
> > > unsigned char ch0 = 0x0;
> > > unsigned char ch1 = 0x0;
> > > long i=0;
> > >
> > > /**** INITIALIZATION ****/
> > > // Frequency initialization
> > > Initialize();
> > > // UART initialization
> > > UART0Initialize(9600);
> > >
> > > init_timer();
> > > InitVIC();
> > >
> > >
> > > while(1)
> > > {
> > >
> > > UART0WriteChar('3');
> > > wait();
> > >
> > > UART0WriteChar('2');
> > > wait();
> > > }
> > >
> > > }
> > >
> > >
> > > void Initialize(void)
> > > {
> > >
> > > // 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=0x2;
> > > MAMTIM=0x4;
> > >
> > > // Setting peripheral Clock (pclk) to System Clock (cclk)
> > > VPBDIV=0x1;
> > >
> > > }
> > >
> > >
> > > void feed(void)
> > > {
> > > PLLFEED=0xAA;
> > > PLLFEED=0x55;
> > > }
> > >
> > > /* Setup the Timer Counter 0 Interrupt */
> > > void init_timer (void) {
> > > T0MR0 = 149999; // 10mSec = 150000-1 counts
> > > T0MCR = 3; // Interrupt and Reset on MR0
> > > T0TCR = 1; // Timer0 Enable
> > > VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
> > > VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
> > > VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0
> Enable
> > > }
> > >
> > > /* Timer0 Compare-Match Interrupt Handler (ISR) */
> > > /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU
> Clock */
> > > /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU
> Clock */
> > > void tc0 (void) __irq
> > > {
> > > ++timeval;
> > > T0IR = 1; // Clear interrupt flag
> > > VICVectAddr = 0; // Acknowledge Interrupt
> > > }
> > > void DefDummyInterrupt(void)__irq
> > > {
> > > ;
> > > }
> > > void InitVIC()
> > > {
> > > VICDefVectAddr = (unsigned long)DefDummyInterrupt;
> > > }
> > >
> > >
> > > /**** UART0 ****/
> > > void UART0Initialize(unsigned int baud)
> > > {
> > > unsigned int divisor = peripheralClockFrequency() / (16 * baud);
> > >
> > > U0LCR = 0x83;
> > >
> > >
> > > //devisor
> > > U0DLL = divisor & 0xFF;
> > > U0DLM = (divisor >> 8) & 0xFF;
> > > U0LCR &= ~0x80;
> > >
> > > //set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
> > > PINSEL0 = PINSEL0 & ~0xF | 0x5;
> > > }
> > >
> > > void UART0WriteChar(unsigned char ch0)
> > > {
> > > //when U0LSR_bit.THRE is 0 - U0THR contains valid data.
> > > while ((U0LSR && 0x20) == 0);
> > > U0THR = ch0;
> > > }
> > >
> > > unsigned char UART0ReadChar(void)
> > > {
> > > //when U0LSR_bit.DR is 1 - U0RBR contains valid data
> > > while ((U0LSR && 0x01) == 0);
> > > return U0RBR;
> > > }
> > > unsigned int processorClockFrequency(void)
> > > {
> > > //return real processor clock speed
> > > return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF)
> +
> > > 1 : 1);
> > > }
> > >
> > > unsigned int peripheralClockFrequency(void)
> > > {
> > > //VPBDIV - determines the relationship between the processor
> clock
> > > (cclk)
> > > //and the clock used by peripheral devices (pclk).
> > > unsigned int divider;
> > > switch (VPBDIV & 3)
> > > {
> > > case 0: divider = 4; break;
> > > case 1: divider = 1; break;
> > > case 2: divider = 2; break;
> > > }
> > > return processorClockFrequency() / divider;
> > > }
> > >
> > > Please look into this and It would be a great help for me as i
> have
> > > been trying for it from past 2 weeks.
> > > I think, abviously iam missing some things. I did not changed 
any
Show quoted textHide quoted text
> > > things in startup.s file.I will post the start up code if any
> body
> > > wanted to look in
> > > please guide me.appreciate your help.
> > >
> > > Thanks
> > >
> >
> 
> 
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
>

RE: [lpc2000] Interrupt in LPC22XX

2006-05-10 by Bennett Scharf

Kicking the watchdog in an interrupt routine is as bad an idea as I have
ever heard.   The only thing that has to be healthy in the microprocessor at
the time is a valid stack pointer and the interrupt routine itself..

 

  _____  
Show quoted textHide quoted text
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf Of
Andrew Berney
Sent: Wednesday, May 10, 2006 2:42 AM
To: lpc2000@yahoogroups.com
Subject: RE: [lpc2000] Interrupt in LPC22XX

 

Errrm I've not looked at the data sheets for that particular part, but it
doesn't appear that you're turning on the serial IRQ...
on the 2129 I'm currently working on it'd be something like:

  VICVectCntl1 = 0x00000026; // IRQ 6 enabled - the IRQ for UART0
  VICVectAddr1 = (unsigned)UART0_Irq; // Function to run as IRQ
  VICIntEnable |= 0x00000040; // flick its bit on to show we want this IRQ
firing...

likewise for UART1:

  VICVectCntl2 = 0x00000027; // IRQ 7 enabled
  VICVectAddr2 = (unsigned)UART1_Irq;
  VICIntEnable |= 0x00000080;

I imagine it's probably the same for yours...

One other thing to note is that your watchdog feed is currently not an
atomic instruction - ie if you get interrupted between the two writes you're
doing the watchdog will trip... (better to disable the IRQ's when kicking
the dog then turn them back on). Personally I simply use one of the on chip
timers to give me an interrupt every so often and then kick the watchdog
inside it's IRQ handler...

Andy


-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of poland459
Sent: 10 May 2006 05:59
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Interrupt in LPC22XX


Hi am new to this forum.I am using "free" KEIL evalution software as
my IDE to work on LPCE2214 OLIMEX board. Am able to work on TIMER and
serial port in "polling" mode. But when I enable ISR functions using
VIC,my program in not jumping to ISR.but in debug mode i could see
the jump to ISR. also I have DefaultISR in my code.here am attaching
my code with this mail.
// This program is created for LPC-E2214 board
#include "lpc22xx.h"

#define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
#define PLOCK 0x400 //in MHz


void Initialize(void);
void feed(void);
void UART0Initialize(unsigned int baud);
void UART0WriteChar(unsigned char ch0);
unsigned char UART0ReadChar(void);
unsigned char UART0ReadChar_nostop(void);
unsigned int processorClockFrequency(void);
unsigned int peripheralClockFrequency(void);

void tc0(void)__irq;
static void DefDummyInterrupt(void)__irq;

void init_timer(void);
void InitVIC(void);

long volatile timeval;

void wait (void) /* wait function */
{
unsigned long i;
i = timeval;
while ((i + 10) != timeval); /* wait 100ms */
}



int main()
{
/**** VARIABLES ****/
unsigned char ch0 = 0x0;
unsigned char ch1 = 0x0;
long i=0;

/**** INITIALIZATION ****/
// Frequency initialization
Initialize();
// UART initialization
UART0Initialize(9600);

init_timer();
InitVIC();


while(1)
{

UART0WriteChar('3');
wait();

UART0WriteChar('2');
wait();
}

}


void Initialize(void)
{

// 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=0x2;
MAMTIM=0x4;

// Setting peripheral Clock (pclk) to System Clock (cclk)
VPBDIV=0x1;

}


void feed(void)
{
PLLFEED=0xAA;
PLLFEED=0x55;
}

/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) {
T0MR0 = 149999; // 10mSec = 150000-1 counts
T0MCR = 3; // Interrupt and Reset on MR0
T0TCR = 1; // Timer0 Enable
VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0 Enable
}

/* Timer0 Compare-Match Interrupt Handler (ISR) */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
void tc0 (void) __irq
{
++timeval;
T0IR = 1; // Clear interrupt flag
VICVectAddr = 0; // Acknowledge Interrupt
}
void DefDummyInterrupt(void)__irq
{
;
}
void InitVIC()
{
VICDefVectAddr = (unsigned long)DefDummyInterrupt;
}


/**** UART0 ****/
void UART0Initialize(unsigned int baud)
{
unsigned int divisor = peripheralClockFrequency() / (16 * baud);

U0LCR = 0x83;


//devisor
U0DLL = divisor & 0xFF;
U0DLM = (divisor >> 8) & 0xFF;
U0LCR &= ~0x80;

//set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
PINSEL0 = PINSEL0 & ~0xF | 0x5;
}

void UART0WriteChar(unsigned char ch0)
{
//when U0LSR_bit.THRE is 0 - U0THR contains valid data.
while ((U0LSR && 0x20) == 0);
U0THR = ch0;
}

unsigned char UART0ReadChar(void)
{
//when U0LSR_bit.DR is 1 - U0RBR contains valid data
while ((U0LSR && 0x01) == 0);
return U0RBR;
}
unsigned int processorClockFrequency(void)
{
//return real processor clock speed
return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF) +
1 : 1);
}

unsigned int peripheralClockFrequency(void)
{
//VPBDIV - determines the relationship between the processor clock
(cclk)
//and the clock used by peripheral devices (pclk).
unsigned int divider;
switch (VPBDIV & 3)
{
case 0: divider = 4; break;
case 1: divider = 1; break;
case 2: divider = 2; break;
}
return processorClockFrequency() / divider;
}

Please look into this and It would be a great help for me as i have
been trying for it from past 2 weeks.
I think, abviously iam missing some things. I did not changed any
things in startup.s file.I will post the start up code if any body
wanted to look in
please guide me.appreciate your help.

Thanks







Yahoo! Groups Links










SPONSORED LINKS 


Microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microcontrollers&w2
=Microprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=c-HXthtbZy4TZbI3ib0PM
g>  

Microprocessor
<http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microcontrollers&w2=M
icroprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=ijt0SspWtjogcHCuFD0lUQ>


Intel
<http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Microcontrolle
rs&w2=Microprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=WOZdpklkgHbXR5qu
Agrl5w>  microprocessors 

 

  _____  

YAHOO! GROUPS LINKS 

 

*	 Visit your group "lpc2000 <http://groups.yahoo.com/group/lpc2000> "
on the web.
  
*	 To unsubscribe from this group, send an email to:
 lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
  
*	 Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/>  Terms of Service. 

 

  _____  



[Non-text portions of this message have been removed]

RE: [lpc2000] Interrupt in LPC22XX

2006-05-10 by Andrew Berney

If you'd care to read the reply I explained exactly what we use that for...
and yes, the original description was unfortunately misleading but has
already been explained so as to avoid any misinterpretation by people such
as yourself.

Andy
Show quoted textHide quoted text
-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of Bennett Scharf
Sent: 10 May 2006 16:20
To: lpc2000@yahoogroups.com
Subject: RE: [lpc2000] Interrupt in LPC22XX


Kicking the watchdog in an interrupt routine is as bad an idea as I have
ever heard.   The only thing that has to be healthy in the microprocessor at
the time is a valid stack pointer and the interrupt routine itself..



  _____

From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf Of
Andrew Berney
Sent: Wednesday, May 10, 2006 2:42 AM
To: lpc2000@yahoogroups.com
Subject: RE: [lpc2000] Interrupt in LPC22XX



Errrm I've not looked at the data sheets for that particular part, but it
doesn't appear that you're turning on the serial IRQ...
on the 2129 I'm currently working on it'd be something like:

  VICVectCntl1 = 0x00000026; // IRQ 6 enabled - the IRQ for UART0
  VICVectAddr1 = (unsigned)UART0_Irq; // Function to run as IRQ
  VICIntEnable |= 0x00000040; // flick its bit on to show we want this IRQ
firing...

likewise for UART1:

  VICVectCntl2 = 0x00000027; // IRQ 7 enabled
  VICVectAddr2 = (unsigned)UART1_Irq;
  VICIntEnable |= 0x00000080;

I imagine it's probably the same for yours...

One other thing to note is that your watchdog feed is currently not an
atomic instruction - ie if you get interrupted between the two writes you're
doing the watchdog will trip... (better to disable the IRQ's when kicking
the dog then turn them back on). Personally I simply use one of the on chip
timers to give me an interrupt every so often and then kick the watchdog
inside it's IRQ handler...

Andy


-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of poland459
Sent: 10 May 2006 05:59
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Interrupt in LPC22XX


Hi am new to this forum.I am using "free" KEIL evalution software as
my IDE to work on LPCE2214 OLIMEX board. Am able to work on TIMER and
serial port in "polling" mode. But when I enable ISR functions using
VIC,my program in not jumping to ISR.but in debug mode i could see
the jump to ISR. also I have DefaultISR in my code.here am attaching
my code with this mail.
// This program is created for LPC-E2214 board
#include "lpc22xx.h"

#define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
#define PLOCK 0x400 //in MHz


void Initialize(void);
void feed(void);
void UART0Initialize(unsigned int baud);
void UART0WriteChar(unsigned char ch0);
unsigned char UART0ReadChar(void);
unsigned char UART0ReadChar_nostop(void);
unsigned int processorClockFrequency(void);
unsigned int peripheralClockFrequency(void);

void tc0(void)__irq;
static void DefDummyInterrupt(void)__irq;

void init_timer(void);
void InitVIC(void);

long volatile timeval;

void wait (void) /* wait function */
{
unsigned long i;
i = timeval;
while ((i + 10) != timeval); /* wait 100ms */
}



int main()
{
/**** VARIABLES ****/
unsigned char ch0 = 0x0;
unsigned char ch1 = 0x0;
long i=0;

/**** INITIALIZATION ****/
// Frequency initialization
Initialize();
// UART initialization
UART0Initialize(9600);

init_timer();
InitVIC();


while(1)
{

UART0WriteChar('3');
wait();

UART0WriteChar('2');
wait();
}

}


void Initialize(void)
{

// 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=0x2;
MAMTIM=0x4;

// Setting peripheral Clock (pclk) to System Clock (cclk)
VPBDIV=0x1;

}


void feed(void)
{
PLLFEED=0xAA;
PLLFEED=0x55;
}

/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) {
T0MR0 = 149999; // 10mSec = 150000-1 counts
T0MCR = 3; // Interrupt and Reset on MR0
T0TCR = 1; // Timer0 Enable
VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0 Enable
}

/* Timer0 Compare-Match Interrupt Handler (ISR) */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
void tc0 (void) __irq
{
++timeval;
T0IR = 1; // Clear interrupt flag
VICVectAddr = 0; // Acknowledge Interrupt
}
void DefDummyInterrupt(void)__irq
{
;
}
void InitVIC()
{
VICDefVectAddr = (unsigned long)DefDummyInterrupt;
}


/**** UART0 ****/
void UART0Initialize(unsigned int baud)
{
unsigned int divisor = peripheralClockFrequency() / (16 * baud);

U0LCR = 0x83;


//devisor
U0DLL = divisor & 0xFF;
U0DLM = (divisor >> 8) & 0xFF;
U0LCR &= ~0x80;

//set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
PINSEL0 = PINSEL0 & ~0xF | 0x5;
}

void UART0WriteChar(unsigned char ch0)
{
//when U0LSR_bit.THRE is 0 - U0THR contains valid data.
while ((U0LSR && 0x20) == 0);
U0THR = ch0;
}

unsigned char UART0ReadChar(void)
{
//when U0LSR_bit.DR is 1 - U0RBR contains valid data
while ((U0LSR && 0x01) == 0);
return U0RBR;
}
unsigned int processorClockFrequency(void)
{
//return real processor clock speed
return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF) +
1 : 1);
}

unsigned int peripheralClockFrequency(void)
{
//VPBDIV - determines the relationship between the processor clock
(cclk)
//and the clock used by peripheral devices (pclk).
unsigned int divider;
switch (VPBDIV & 3)
{
case 0: divider = 4; break;
case 1: divider = 1; break;
case 2: divider = 2; break;
}
return processorClockFrequency() / divider;
}

Please look into this and It would be a great help for me as i have
been trying for it from past 2 weeks.
I think, abviously iam missing some things. I did not changed any
things in startup.s file.I will post the start up code if any body
wanted to look in
please guide me.appreciate your help.

Thanks







Yahoo! Groups Links










SPONSORED LINKS


Microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microcontrollers&w2
=Microprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=c-HXthtbZy4TZbI3ib0PM
g>

Microprocessor
<http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microcontrollers&w2=M
icroprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=ijt0SspWtjogcHCuFD0lUQ>


Intel
<http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Microcontrolle
rs&w2=Microprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=WOZdpklkgHbXR5qu
Agrl5w>  microprocessors



  _____

YAHOO! GROUPS LINKS



*	 Visit your group "lpc2000 <http://groups.yahoo.com/group/lpc2000> "
on the web.

*	 To unsubscribe from this group, send an email to:
 lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>

*	 Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/>  Terms of Service.



  _____



[Non-text portions of this message have been removed]





Yahoo! Groups Links

RE: [lpc2000] Interrupt in LPC22XX

2006-05-10 by Bennett Scharf

Sorry Andy. I joined the group yesterday and did not read your reply until
after I sent mine!.

Bennett

 

  _____  
Show quoted textHide quoted text
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf Of
Andrew Berney
Sent: Wednesday, May 10, 2006 9:30 AM
To: lpc2000@yahoogroups.com
Subject: RE: [lpc2000] Interrupt in LPC22XX

 

If you'd care to read the reply I explained exactly what we use that for...
and yes, the original description was unfortunately misleading but has
already been explained so as to avoid any misinterpretation by people such
as yourself.

Andy

-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of Bennett Scharf
Sent: 10 May 2006 16:20
To: lpc2000@yahoogroups.com
Subject: RE: [lpc2000] Interrupt in LPC22XX


Kicking the watchdog in an interrupt routine is as bad an idea as I have
ever heard.   The only thing that has to be healthy in the microprocessor at
the time is a valid stack pointer and the interrupt routine itself..



  _____

From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf Of
Andrew Berney
Sent: Wednesday, May 10, 2006 2:42 AM
To: lpc2000@yahoogroups.com
Subject: RE: [lpc2000] Interrupt in LPC22XX



Errrm I've not looked at the data sheets for that particular part, but it
doesn't appear that you're turning on the serial IRQ...
on the 2129 I'm currently working on it'd be something like:

  VICVectCntl1 = 0x00000026; // IRQ 6 enabled - the IRQ for UART0
  VICVectAddr1 = (unsigned)UART0_Irq; // Function to run as IRQ
  VICIntEnable |= 0x00000040; // flick its bit on to show we want this IRQ
firing...

likewise for UART1:

  VICVectCntl2 = 0x00000027; // IRQ 7 enabled
  VICVectAddr2 = (unsigned)UART1_Irq;
  VICIntEnable |= 0x00000080;

I imagine it's probably the same for yours...

One other thing to note is that your watchdog feed is currently not an
atomic instruction - ie if you get interrupted between the two writes you're
doing the watchdog will trip... (better to disable the IRQ's when kicking
the dog then turn them back on). Personally I simply use one of the on chip
timers to give me an interrupt every so often and then kick the watchdog
inside it's IRQ handler...

Andy


-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com]On Behalf
Of poland459
Sent: 10 May 2006 05:59
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Interrupt in LPC22XX


Hi am new to this forum.I am using "free" KEIL evalution software as
my IDE to work on LPCE2214 OLIMEX board. Am able to work on TIMER and
serial port in "polling" mode. But when I enable ISR functions using
VIC,my program in not jumping to ISR.but in debug mode i could see
the jump to ISR. also I have DefaultISR in my code.here am attaching
my code with this mail.
// This program is created for LPC-E2214 board
#include "lpc22xx.h"

#define OSCILLATOR_CLOCK_FREQUENCY 14745600 //in MHz
#define PLOCK 0x400 //in MHz


void Initialize(void);
void feed(void);
void UART0Initialize(unsigned int baud);
void UART0WriteChar(unsigned char ch0);
unsigned char UART0ReadChar(void);
unsigned char UART0ReadChar_nostop(void);
unsigned int processorClockFrequency(void);
unsigned int peripheralClockFrequency(void);

void tc0(void)__irq;
static void DefDummyInterrupt(void)__irq;

void init_timer(void);
void InitVIC(void);

long volatile timeval;

void wait (void) /* wait function */
{
unsigned long i;
i = timeval;
while ((i + 10) != timeval); /* wait 100ms */
}



int main()
{
/**** VARIABLES ****/
unsigned char ch0 = 0x0;
unsigned char ch1 = 0x0;
long i=0;

/**** INITIALIZATION ****/
// Frequency initialization
Initialize();
// UART initialization
UART0Initialize(9600);

init_timer();
InitVIC();


while(1)
{

UART0WriteChar('3');
wait();

UART0WriteChar('2');
wait();
}

}


void Initialize(void)
{

// 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=0x2;
MAMTIM=0x4;

// Setting peripheral Clock (pclk) to System Clock (cclk)
VPBDIV=0x1;

}


void feed(void)
{
PLLFEED=0xAA;
PLLFEED=0x55;
}

/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) {
T0MR0 = 149999; // 10mSec = 150000-1 counts
T0MCR = 3; // Interrupt and Reset on MR0
T0TCR = 1; // Timer0 Enable
VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0
VICVectCntl0 = 0x20 | 4; // use it for Timer 0 Interrupt
VICIntEnable = 0x00000010; // Enable Timer0 Interrupt // Timer0 Enable
}

/* Timer0 Compare-Match Interrupt Handler (ISR) */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
void tc0 (void) __irq
{
++timeval;
T0IR = 1; // Clear interrupt flag
VICVectAddr = 0; // Acknowledge Interrupt
}
void DefDummyInterrupt(void)__irq
{
;
}
void InitVIC()
{
VICDefVectAddr = (unsigned long)DefDummyInterrupt;
}


/**** UART0 ****/
void UART0Initialize(unsigned int baud)
{
unsigned int divisor = peripheralClockFrequency() / (16 * baud);

U0LCR = 0x83;


//devisor
U0DLL = divisor & 0xFF;
U0DLM = (divisor >> 8) & 0xFF;
U0LCR &= ~0x80;

//set functionalite to pins: port0.0 -> TX0, port0.1 -> RXD0
PINSEL0 = PINSEL0 & ~0xF | 0x5;
}

void UART0WriteChar(unsigned char ch0)
{
//when U0LSR_bit.THRE is 0 - U0THR contains valid data.
while ((U0LSR && 0x20) == 0);
U0THR = ch0;
}

unsigned char UART0ReadChar(void)
{
//when U0LSR_bit.DR is 1 - U0RBR contains valid data
while ((U0LSR && 0x01) == 0);
return U0RBR;
}
unsigned int processorClockFrequency(void)
{
//return real processor clock speed
return OSCILLATOR_CLOCK_FREQUENCY * (PLLCON & 1 ? (PLLCFG & 0xF) +
1 : 1);
}

unsigned int peripheralClockFrequency(void)
{
//VPBDIV - determines the relationship between the processor clock
(cclk)
//and the clock used by peripheral devices (pclk).
unsigned int divider;
switch (VPBDIV & 3)
{
case 0: divider = 4; break;
case 1: divider = 1; break;
case 2: divider = 2; break;
}
return processorClockFrequency() / divider;
}

Please look into this and It would be a great help for me as i have
been trying for it from past 2 weeks.
I think, abviously iam missing some things. I did not changed any
things in startup.s file.I will post the start up code if any body
wanted to look in
please guide me.appreciate your help.

Thanks







Yahoo! Groups Links










SPONSORED LINKS


Microcontrollers
<http://groups.yahoo.com/gads?t=ms
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microcontrollers&w2
> &k=Microcontrollers&w1=Microcontrollers&w2
=Microprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=c-HXthtbZy4TZbI3ib0PM
g>

Microprocessor
<http://groups.yahoo.com/gads?t=ms
<http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microcontrollers&w2=M
> &k=Microprocessor&w1=Microcontrollers&w2=M
icroprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=ijt0SspWtjogcHCuFD0lUQ>


Intel
<http://groups.yahoo.com/gads?t=ms
<http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Microcontrolle
> &k=Intel+microprocessors&w1=Microcontrolle
rs&w2=Microprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=WOZdpklkgHbXR5qu
Agrl5w>  microprocessors



  _____

YAHOO! GROUPS LINKS



*      Visit your group "lpc2000 <http://groups.yahoo.com/group/lpc2000> "
on the web.

*      To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>

*      Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/>  Terms of Service.



  _____



[Non-text portions of this message have been removed]





Yahoo! Groups Links










SPONSORED LINKS 


Microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microcontrollers&w2
=Microprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=c-HXthtbZy4TZbI3ib0PM
g>  

Microprocessor
<http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microcontrollers&w2=M
icroprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=ijt0SspWtjogcHCuFD0lUQ>


Intel
<http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Microcontrolle
rs&w2=Microprocessor&w3=Intel+microprocessors&c=3&s=69&.sig=WOZdpklkgHbXR5qu
Agrl5w>  microprocessors 

 

  _____  

YAHOO! GROUPS LINKS 

 

*	 Visit your group "lpc2000 <http://groups.yahoo.com/group/lpc2000> "
on the web.
  
*	 To unsubscribe from this group, send an email to:
 lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
  
*	 Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/>  Terms of Service. 

 

  _____  



[Non-text portions of this message have been removed]

Re: [lpc2000] Interrupt in LPC22XX

2006-05-10 by 3gpabko

Here are some points to mention:
1. As I see you are running from FLASH. Correct? If
yes you need to set MEMMAP = 1, at initialization.
2. In this case ensure that at address 0x00000018 you
have this:
 ldr pc, [pc, #-0xFF0]
or similar code.


Regards
Zdravko Dimitrov

 

--- poland459 <poland459@...> wrote:

> Hi am new to this forum.I am using "free" KEIL
> evalution software as 
> my IDE to work on LPCE2214 OLIMEX board. Am able to
> work on TIMER and 
> serial port in "polling" mode. But when I enable ISR
> functions using 
> VIC,my program in not jumping to ISR.but in debug
> mode i could see 
> the jump to ISR. also I have DefaultISR in my
> code.here am attaching 
> my code with this mail.
> ,,,, 


\u0417\u043d\u0430\u043d\u0438\u0435\u0442\u043e \u0435 \u043b\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0436\u0438\u0432\u044f\u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u0430.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

Re: Interrupt in LPC22XX

2006-05-10 by ghetto_shinobi

Ive taken look into ur code and since u are using Keils IDE its
pointless to call this function
void Initialize(void);

This piece of code is embedded into startup code and u can configure
speed of Mcu(PLL and VPBDIV and MEM either by editing startup code or
by using Configuration Wizard.

Regards!!

Re: Interrupt in LPC22XX

2006-05-11 by poland459

Hi Zdravko Dimitrov,

Thank you very much for your valid suggestion.

At last its working..really Its 2 weeks struggle..I thought I have 
initialised "MEMMAP = 1" but forgot to initialise. Am very thank ful 
to you and everyone who tried to help me out.



--- In lpc2000@yahoogroups.com, 3gpabko <zdravko_k_d@...> wrote:
>
> Here are some points to mention:
> 1. As I see you are running from FLASH. Correct? If
> yes you need to set MEMMAP = 1, at initialization.
> 2. In this case ensure that at address 0x00000018 you
> have this:
>  ldr pc, [pc, #-0xFF0]
> or similar code.
> 
> 
> Regards
> Zdravko Dimitrov
> 
>  
> 
> --- poland459 <poland459@...> wrote:
> 
> > Hi am new to this forum.I am using "free" KEIL
> > evalution software as 
> > my IDE to work on LPCE2214 OLIMEX board. Am able to
> > work on TIMER and 
> > serial port in "polling" mode. But when I enable ISR
> > functions using 
> > VIC,my program in not jumping to ISR.but in debug
> > mode i could see 
> > the jump to ISR. also I have DefaultISR in my
> > code.here am attaching 
> > my code with this mail.
> > ,,,, 
> 
> 
> \u0417\u043d\u0430;\u043d\u0438\u0435\u0442\u043e \u0435 
\u043b\u0438\u0447\u043d&#1086; 
\u043f\u0440\u0435\u0436\u0438\u0432\u044f\u043d\u0430 
&#1080;\u0441\u0442\u0438\u043d\u0430.
Show quoted textHide quoted text
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com
>

Re: Interrupt in LPC22XX

2006-05-11 by Tom OE6TKT

>   VICIntEnable |= 0x00000080;
> 
You don't need to OR this register with itself, just write:
VICIntEnable = 0x00000080;
(to clear this interrupt use VICIntEnClear = 0x00000080;)

Thomas

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.