Sign in

username:

password:



Not a member?

Search lpc2000



Search tips

Subscribe to lpc2000



lpc2000 by Keywords

2106 | ADC | ARM7 | Atmel | Bootloader | CAN | CrossStudio | CrossWorks | DDS | ECos | Ethernet | ETM | FIFO | FLASH | FPGA | GCC | GDB | GNU | GNUARM | GPIO | I2C | IAP | IAR | JTAG | Kickstart | LCD | Linux | LPC | LPC-E2294 | LPC2000 | LPC2100 | LPC2104 | Lpc2106 | Lpc210x | LPC2114 | LPC2119 | LPC2124 | LPC2129 | Lpc2138 | LPC213x | LPC21xx | LPC2210 | LPC2212 | LPC2214 | LPC2292 | LPC2294 | LPC2xxx | LPC3128 | MCB2100 | Olimex | Philips | PWM | Rowley | RTC | RTOS | SPI | SSP | UART | UART0 | UART1 | ULINK | USB | Watchdog | Wiggler

Sponsor

controlSUITE™ software
Comprehensive.
Intuitive.
Optimized.

Real-world software for real-time control. Details Here!

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | LPC2000 | interrupts + Keil + LPC2294

Discussion group dedicated to the Philips LPC2000 family of ARM MCUs

interrupts + Keil + LPC2294 - grodo2k - Mar 21 7:38:00 2006

Hello
could someone be so kind and say, what is wrong in following code? Or
maybe it is ok, but it doesn't work... I want trigger an interrupt
using UART0. I am using Keil. (UART0 is ok, it sends a string from tab).

thanks in advance

int i,j;
char tab[] = "UART0 is working properly";

void UART0INT() __irq
{
	IO0CLR |= 0x20000;  //clr P0.17 (it's a LED)
	for(i=0;i<5;i++)
	{
		for(j=0;j<50000;j++){}
	}
	send_char_u0('A');
	VICVectAddr = 0x00000000; //dummy write
}

int main(void) 
{
	PLL_ON();
	LED_init();
	VPBDIV = 0x1;   
	UART0_init();                            
	IO0SET |= 0x20000;  //set P0.17
	send_string_u0(tab);
	VICIntSelect = 0x00000000;
	VICVectAddr0 = (unsigned) UART0INT;
	VICVectCntl0  = 0x26;	//UART0	
	VICIntEnable = 0x40;		//bit 6 = UART0
	while(1)
	{

	}
	
	return 0;

}
	


(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )


RE: interrupts + Keil + LPC2294 - Andrew Berney - Mar 21 12:03:00 2006

Hi,

we could do with the function UART0_init from your code, however I suspect
your problem is that you're not reading U0IIR to clear the UART IRQ. You
also have a huge delay inside your IRQ which kind of defeats the point of
using it. Have a look at the description of U0IIR register.

Here is a working example from a 2129 which should work equally well on your
chip with minor modification:

void main(void)
{
  // init the serial ports
  init_serial();

  // main loop
  while(1)
  {
    for(;;);
  }
}

void init_serial (void)    	// Initialize Serial Interface
  {

  //UART0
  VPBDIV  = 0x00000001;	    //Set PClk to 60Mhz
  PINSEL0 = 0x00000005;     //Enable TxD0, RxD0

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

  VICVectCntl1 = 0x00000026;
  VICVectAddr1 = (unsigned)uart0_irq;
  VICIntEnable |= 0x00000040;

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

static unsigned int U0IIR_copy;

void uart0_irq(void) __irq
{
  //check for a character from the UART0 RX FIFO
  if((U0LSR & 0x01) == 0x01)  //if there is a character
  {
    toggle_LED(1);		//do this to suit your board
  }

  //exit ISR
  U0IIR_copy = U0IIR;
  VICVectAddr = 0x00000000; 	//dummy write to re-enable interrupt for next
time
}
	-----Original Message-----
From: lpc2000@lpc2... [mailto:lpc2000@lpc2...]On Behalf
Of grodo2k
Sent: 21 March 2006 11:38
To: lpc2000@lpc2...
Subject: [lpc2000] interrupts + Keil + LPC2294
	Hello
could someone be so kind and say, what is wrong in following code? Or
maybe it is ok, but it doesn't work... I want trigger an interrupt
using UART0. I am using Keil. (UART0 is ok, it sends a string from tab).

thanks in advance

int i,j;
char tab[] = "UART0 is working properly";

void UART0INT() __irq
{
	IO0CLR |= 0x20000;  //clr P0.17 (it's a LED)
	for(i=0;i<5;i++)
	{
		for(j=0;j<50000;j++){}
	}
	send_char_u0('A');
	VICVectAddr = 0x00000000; //dummy write
}

int main(void)
{
	PLL_ON();
	LED_init();
	VPBDIV = 0x1;
	UART0_init();
	IO0SET |= 0x20000;  //set P0.17
	send_string_u0(tab);
	VICIntSelect = 0x00000000;
	VICVectAddr0 = (unsigned) UART0INT;
	VICVectCntl0  = 0x26;	//UART0
	VICIntEnable = 0x40;		//bit 6 = UART0
	while(1)
	{

	}

	return 0;

}
	Yahoo! Groups Links
	


(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

RE: interrupts + Keil + LPC2294 - Grodo Grodo - Mar 21 15:30:00 2006

Thank you, I'll try it and say if it works by me.

Andrew Berney <amb@amb@...> wrote:          Hi,
  
  we could do with the function UART0_init from your code, however I suspect
  your problem is that you're not reading U0IIR to clear the UART IRQ. You
  also have a huge delay inside your IRQ which kind of defeats the point of
  using it. Have a look at the description of U0IIR register.
  
  Here is a working example from a 2129 which should work equally well on your
  chip with minor modification:
  
  void main(void)
  {
    // init the serial ports
    init_serial();
  
    // main loop
    while(1)
    {
      for(;;);
    }
  }
  
  void init_serial (void)          // Initialize Serial Interface
    {
  
    //UART0
    VPBDIV  = 0x00000001;          //Set PClk to 60Mhz
    PINSEL0 = 0x00000005;     //Enable TxD0, RxD0
  
    U0LCR   = 0x00000083;     //8 bits, no Parity, 1 Stop bit
    U0DLL   = 0x00000084;     // 9600 Baud Rate @ 60MHz VPB Clock
    U0DLM   = 0x00000001;
    U0LCR   = 0x00000003;     // DLAB = 0
    U0IER   = 0x00000001;     //enable rx data available interrupt
  
    VICVectCntl1 = 0x00000026;
    VICVectAddr1 = (unsigned)uart0_irq;
    VICIntEnable |= 0x00000040;
  
    U0FCR   = 0x00000001;             //Enable FIFO & trigger level to 1  bytes
  }
  
  static unsigned int U0IIR_copy;
  
  void uart0_irq(void) __irq
  {
    //check for a character from the UART0 RX FIFO
    if((U0LSR & 0x01) == 0x01)  //if there is a character
    {
      toggle_LED(1);            //do this to suit your board
    }
  
    //exit ISR
    U0IIR_copy = U0IIR;
    VICVectAddr = 0x00000000;       //dummy write to re-enable interrupt for next
  time
  }
	  -----Original Message-----
  From: lpc2000@lpc2... [mailto:lpc2000@lpc2...]On Behalf
  Of grodo2k
  Sent: 21 March 2006 11:38
  To: lpc2000@lpc2...
  Subject: [lpc2000] interrupts + Keil + LPC2294
	  Hello
  could someone be so kind and say, what is wrong in following code? Or
  maybe it is ok, but it doesn't work... I want trigger an interrupt
  using UART0. I am using Keil. (UART0 is ok, it sends a string from tab).
  
  thanks in advance
  
  int i,j;
  char tab[] = "UART0 is working properly";
  
  void UART0INT() __irq
  {
        IO0CLR |= 0x20000;  //clr P0.17 (it's a LED)
        for(i=0;i<5;i++)
        {
              for(j=0;j<50000;j++){}
        }
        send_char_u0('A');
        VICVectAddr = 0x00000000; //dummy write
  }
  
  int main(void)
  {
        PLL_ON();
        LED_init();
        VPBDIV = 0x1;
        UART0_init();
        IO0SET |= 0x20000;  //set P0.17
        send_string_u0(tab);
        VICIntSelect = 0x00000000;
        VICVectAddr0 = (unsigned) UART0INT;
        VICVectCntl0  = 0x26;      //UART0
        VICIntEnable = 0x40;            //bit 6 = UART0
        while(1)
        {
  
        }
  
        return 0;
  
  }
	  Yahoo! Groups Links
	          SPONSORED LINKS    
                                                        Microcontrollers                  
                       Microprocessor                                          Intel
microprocessors                                                                         
Pic microcontrollers                                                             
        
---------------------------------
    YAHOO! GROUPS LINKS
	---------------------------------
	---------------------------------
Yahoo! Travel
 Find  great deals to the top 10 hottest destinations!

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


(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

RE: interrupts + Keil + LPC2294 - Grodo Grodo - Mar 26 7:39:00 2006

Andrew, thank you very much ;) In fact I am working with CrossWorks but  I coudn't
trigger any interrupt there, so I thought, maybe I will do it  in Keil. But it didn't work
either. Now it is working ;) It helped me  much, thanks again ;)

Grodo Grodo <grodo2k@grod...> wrote:          Thank you, I'll try it and say if it
works by me.
  
  Andrew Berney <amb@amb@...> wrote:          Hi,
    
    we could do with the function UART0_init from your code, however I suspect
    your problem is that you're not reading U0IIR to clear the UART IRQ. You
    also have a huge delay inside your IRQ which kind of defeats the point of
    using it. Have a look at the description of U0IIR register.
    
    Here is a working example from a 2129 which should work equally well on your
    chip with minor modification:
    
    void main(void)
    {
      // init the serial ports
      init_serial();
    
      // main loop
      while(1)
      {
        for(;;);
      }
    }
    
    void init_serial (void)          // Initialize Serial Interface
      {
    
      //UART0
      VPBDIV  = 0x00000001;          //Set PClk to 60Mhz
      PINSEL0 = 0x00000005;     //Enable TxD0, RxD0
    
      U0LCR   = 0x00000083;     //8 bits, no Parity, 1 Stop bit
      U0DLL   = 0x00000084;     // 9600 Baud Rate @ 60MHz VPB Clock
      U0DLM   = 0x00000001;
      U0LCR   = 0x00000003;     // DLAB = 0
      U0IER   = 0x00000001;     //enable rx data available interrupt
    
      VICVectCntl1 = 0x00000026;
      VICVectAddr1 = (unsigned)uart0_irq;
      VICIntEnable |= 0x00000040;
    
      U0FCR   =  0x00000001;              //Enable FIFO & trigger level to 1  bytes
    }
    
    static unsigned int U0IIR_copy;
    
    void uart0_irq(void) __irq
    {
      //check for a character from the UART0 RX FIFO
      if((U0LSR & 0x01) == 0x01)  //if there is a character
      {
         toggle_LED(1);             //do this to suit your board
      }
    
      //exit ISR
      U0IIR_copy = U0IIR;
      VICVectAddr = 0x00000000;       //dummy write to re-enable interrupt for next
    time
    }
	    -----Original Message-----
    From: lpc2000@lpc2... [mailto:lpc2000@lpc2...]On Behalf
    Of grodo2k
    Sent: 21 March 2006 11:38
    To: lpc2000@lpc2...
    Subject: [lpc2000] interrupts + Keil + LPC2294
	    Hello
    could someone be so kind and say, what is wrong in following code? Or
    maybe it is ok, but it doesn't work... I want trigger an interrupt
    using UART0. I am using Keil. (UART0 is ok, it sends a string from tab).
    
    thanks in advance
    
    int i,j;
    char tab[] = "UART0 is working properly";
    
    void UART0INT() __irq
    {
          IO0CLR |= 0x20000;  //clr P0.17 (it's a LED)
          for(i=0;i<5;i++)
          {
                for(j=0;j<50000;j++){}
          }
          send_char_u0('A');
          VICVectAddr = 0x00000000; //dummy write
    }
    
    int main(void)
    {
          PLL_ON();
          LED_init();
          VPBDIV = 0x1;
          UART0_init();
          IO0SET |= 0x20000;  //set P0.17
          send_string_u0(tab);
          VICIntSelect = 0x00000000;
          VICVectAddr0 = (unsigned) UART0INT;
          VICVectCntl0  = 0x26;      //UART0
          VICIntEnable =  0x40;             //bit 6 = UART0
          while(1)
          {
    
          }
    
          return 0;
    
    }
	    Yahoo! Groups Links
	            SPONSORED LINKS    
                                                           Microcontrollers               
                           Microprocessor                                           Intel 
microprocessors                                                                          
Pic  microcontrollers                                                              
          
  ---------------------------------
      YAHOO! GROUPS LINKS
	  ---------------------------------
	  ---------------------------------
  Yahoo! Travel
   Find  great deals to the top 10 hottest destinations!
  
  [Non-text portions of this message have been removed]
	          SPONSORED LINKS    
                                                        Microcontrollers                  
                       Microprocessor                                          Intel
microprocessors                                                                         
Pic microcontrollers                                                             
        
---------------------------------
    YAHOO! GROUPS LINKS
	---------------------------------
	---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

[Non-text portions of this message have been removed]
	
______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )