Forums

Crossworks & Interrupts

Started by stephenl April 8, 2012
Hello
I'm new to both ARM and Crossworks and trying to understand interrupts, i
order
to do so, i've created a small serial program to echo characters received,
however it never seems to call the ISR. Ive tried adding
VECTORED_IRQ_INTERRUPTS and STARTUP_FROM_RESET to the Preprocessor
Definitions
section of the startup.s file...
I would appreciate a little guidance

Program as follows :-

#include "targets/LPC210X.H"

#define Fosc 12000000 // Crystal Frequency
#define Fcclk (Fosc * 5) // System Frequency
#define Fcco (Fcclk * 4) // CCO Frequency
#define Fpclk (Fcclk / 4) * 1 // VPB Clock Frequency

unsigned char rec;
unsigned char rec_new;

/**********************************************************************
IRQ_UART0()
**********************************************************************/
void IRQ_UART0 () __attribute__ ((interrupt ("IRQ")));
void IRQ_UART0 () {
if( (U0IIR&0x0F)==0x04 )
{
rec = U0RBR;
rec_new = 1;
}
VICVectAddr = 0x00;
}
/**********************************************************************
SendByte()
**********************************************************************/
void SendByte(unsigned char data)
{
U0THR = data;
while( (U0LSR & 0x20)==0 );
}
/**********************************************************************
UART0_Ini()
**********************************************************************/
unsigned char
UART0_Ini(unsigned int baud)
{
unsigned long temp;

U0LCR = 0x80; // Line Control Register = DLAB
temp = (Fpclk / 16)/baud;
U0DLM = temp / 256; // Divisor Latch MSB
U0DLL = temp % 256; // Divisor Latch LSB
U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bit
U0LCR = 0x03; // DLAB = 0

return(1);
}
/**********************************************************************
Main()
**********************************************************************/
int main(void)
{
PINSEL0 = 0x00000005; // GPIO = TXD (UART0) & RxD (UART0)
PINSEL1 = 0x00000000; // No Change from Reset

rec_new = 0; // Reset rec_new flag

UART0_Ini(115200); // Set Baud Rate and intalise UART

U0FCR = 0x01; // FIFO Control Register - Enable FIFO
U0IER = 0x01; // Interrupt Enable Register - Enable RX Data
Available Interrupt

VICIntSelect = 0x00000000; // Clear Interrupt Select register
VICVectCntl0 = 0x26; // UART0 IRQ slot 0
VICVectAddr0 = (int)IRQ_UART0; // Address of URAT0 ISR
VICIntEnable = 0x00000040; // Enable Interrupts - UART0

while(1)
{
if(rec_new==1)
{
SendByte(rec);
if (rec==0x0D)
SendByte(0X0A);
rec_new = 0;
}
}
return 0;
}


Thank you


	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
On 04/08/2012 08:13 PM, stephenl wrote:
> Hello > I'm new to both ARM and Crossworks and trying to understand interrupts, i > order > to do so, i've created a small serial program to echo characters received, > however it never seems to call the ISR. Ive tried adding > VECTORED_IRQ_INTERRUPTS and STARTUP_FROM_RESET to the Preprocessor > Definitions > section of the startup.s file... > I would appreciate a little guidance
It looks like you never enable global IRQs in the ARM core CPSR register. When the ARM comes out of reset, all interrupts are disabled. I am not familiar with Crossworks, so I don't know if they have a library call for that.
On Sun, 08 Apr 2012 20:35:27 +0200, Arlet Ottens <usenet+5@c-scape.nl>
wrote:

>On 04/08/2012 08:13 PM, stephenl wrote: >> Hello >> I'm new to both ARM and Crossworks and trying to understand interrupts, i >> order >> to do so, i've created a small serial program to echo characters received, >> however it never seems to call the ISR. Ive tried adding >> VECTORED_IRQ_INTERRUPTS and STARTUP_FROM_RESET to the Preprocessor >> Definitions >> section of the startup.s file... >> I would appreciate a little guidance > >It looks like you never enable global IRQs in the ARM core CPSR >register. When the ARM comes out of reset, all interrupts are disabled. > >I am not familiar with Crossworks, so I don't know if they have a >library call for that.
Good catch. The OP can include <intrinsics.h> and use __enable_interrupt() and __disable_interrupt() to en/disable global interrupts. If/when he starts using the CTL (the RTOS they provide) switch to <ctl.h> and use ctl_global_interrupts_enable() or ... _disable(). He also ought to include a handler for spurious interrupts -- Rich Webb Norfolk, VA