Motherboard Forums


Reply
Thread Tools Display Modes

Crossworks & Interrupts

 
 
stephenl
Guest
Posts: n/a
 
      04-08-2012, 06:13 PM
Hello
I'm new to both ARM and Crossworks and trying to understand interrupts,
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 Preprocesso
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
 
Reply With Quote
 
 
 
 
Arlet Ottens
Guest
Posts: n/a
 
      04-08-2012, 06:35 PM
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.



 
Reply With Quote
 
 
 
 
Rich Webb
Guest
Posts: n/a
 
      04-08-2012, 07:24 PM
On Sun, 08 Apr 2012 20:35:27 +0200, Arlet Ottens <(E-Mail Removed)>
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crossworks vs. ez430 USB? larwe Embedded 4 01-13-2008 09:04 PM
Opinions on Rowley CrossWorks for ARM Sebastian Schildt Embedded 77 12-23-2006 03:55 PM
Does Crossworks for ARM supports LPC2103 ? Mochuelo Embedded 7 06-02-2006 04:21 PM
Re: Anyone know (CTL) Crossworks Task Library ? Daniel Embedded 1 03-03-2006 11:55 AM
Debugging by bsing SW interrupts instead of HW interrupts istakoz2000@yahoo.com Embedded 4 08-19-2005 01:32 PM


All times are GMT. The time now is 06:52 PM.


Welcome!
Welcome to Motherboard Point
 

Advertisment