Yahoo Groups archive

Lpc2000

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

Message

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

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

Attachments

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.