1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Crossworks & Interrupts

Discussion in 'Embedded' started by stephenl, Apr 8, 2012.

  1. stephenl

    stephenl Guest

    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
    stephenl, Apr 8, 2012
    #1
    1. Advertising

  2. stephenl

    Arlet Ottens Guest

    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.
    Arlet Ottens, Apr 8, 2012
    #2
    1. Advertising

  3. stephenl

    Rich Webb Guest

    On Sun, 08 Apr 2012 20:35:27 +0200, Arlet Ottens <>
    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
    Rich Webb, Apr 8, 2012
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    476
    Steve at fivetrees
    Aug 19, 2005
  2. Daniel
    Replies:
    1
    Views:
    537
    Richard
    Mar 3, 2006
  3. Mochuelo
    Replies:
    7
    Views:
    323
    Mochuelo
    Jun 2, 2006
  4. Sebastian Schildt

    Opinions on Rowley CrossWorks for ARM

    Sebastian Schildt, Oct 30, 2006, in forum: Embedded
    Replies:
    77
    Views:
    11,371
    Colin Paul Gloster
    Dec 23, 2006
  5. larwe

    Crossworks vs. ez430 USB?

    larwe, Jan 13, 2008, in forum: Embedded
    Replies:
    4
    Views:
    321
    larwe
    Jan 13, 2008
Loading...

Share This Page