EmbDev.net

Forum: ARM programming with GCC/GNU tools LPC2103 - UART0 Interrupt Problem


von Jongmun K. (Company: inno) (jmkim519)


Rate this post
useful
not useful
Dear all,

I am Using LPC2103, I had Configured UART0 to IRQ

When working, VIC Register Status is
 -------------------------------------------
  vicIntSelect = 0;
  vicIntEnable = 0x000040;
  vicIRQStatus = 00000040;

  vicVectCtrl0 = 0x000026;
  vicVectAddr0 = 0x000380;
  vicVectAddr  = 0x000380;
 -------------------------------------------

But Didn't happen to uart0_rx_isr Routine

Could some body help me regarding this.


 -------------------------------------------
          /* Exception Vector Table */

_vectors:       ldr     PC, Reset_Addr
                ldr     PC, Undef_Addr
                ldr     PC, SWI_Addr
                ldr     PC, PAbt_Addr
                ldr     PC, DAbt_Addr
                nop
                ldr     PC, [PC,#-0xFF0]
                ldr     PC, FIQ_Addr

 -------------------------------------------
           /* My Working Code */

#include "LPC210x.h"

void uart0_rx_isr(void);

int main()
{
        PINSEL0 &= (~(0xF) & 0xFFFFFFFF);
        PINSEL0 |= 0x5;

        UART0_FCR = 0x7;
        UART0_LCR = 0x83;
        UART0_DLL = 0x41;

        UART0_DLM = 0x0;
        UART0_LCR = 0x3;

        /* Setting Interrupt */
        UART0_IER = 0x3;
        VICIntEnClr     = 0xFFFFFFF0;
        VICIntSelect    = 0x00000000;
        VICVectCntl0    = ((0x1<<5) | 6);
        VICVectAddr0    = (unsigned long)uart0_rx_isr;

        VICIntEnable    = (1<<6);
}

void uart0_rx_isr(void)
{
        volatile unsigned long uart0IIR = 0;

        uart0IIR = UART0_IIR;

        while (!(UART0_LSR & 1<<5));
        UART0_THR = 'T';

        VICVectAddr = 0;
}

von (prx) A. K. (prx)


Rate this post
useful
not useful
Is the processor interrupt enabled? ARM7 startup codes often call main() 
with interrupts disabled and your main enables the interrupts in VIC but 
not in the processor. Also it is rather undefined what happens once 
main() terminates.

BTW: A local variable of an interrupt handler almost never has to be 
"volatile". Only vars which could be accessed outside of the compilers 
visibility have to be volatile (such as a main program's var accessed by 
an interrupt handler).

von Jongmun K. (Company: inno) (jmkim519)


Rate this post
useful
not useful
Thx. For your help.
But I am a beginner, I don't know exactly.
Here My startup code, For processor interrupt Enable, what I have to do?
1
/* Stack Sizes */
2
.set  UND_STACK_SIZE, 0x00000004    /* stack for "undefined instruction" interrupts is 4 bytes  */
3
.set  ABT_STACK_SIZE, 0x00000004    /* stack for "abort" interrupts is 4 bytes                  */
4
.set  FIQ_STACK_SIZE, 0x00000004    /* stack for "FIQ" interrupts  is 4 bytes               */
5
.set  IRQ_STACK_SIZE, 0X00000004    /* stack for "IRQ" normal interrupts is 4 bytes          */
6
.set  SVC_STACK_SIZE, 0x00000004    /* stack for "SVC" supervisor mode is 4 bytes          */
7
8
9
10
/* Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs (program status registers) */
11
.set  MODE_USR, 0x10                /* Normal User Mode                     */
12
.set  MODE_FIQ, 0x11                /* FIQ Processing Fast Interrupts Mode             */
13
.set  MODE_IRQ, 0x12                /* IRQ Processing Standard Interrupts Mode           */
14
.set  MODE_SVC, 0x13                /* Supervisor Processing Software Interrupts Mode       */
15
.set  MODE_ABT, 0x17                /* Abort Processing memory Faults Mode             */
16
.set  MODE_UND, 0x1B                /* Undefined Processing Undefined Instructions Mode     */
17
.set  MODE_SYS, 0x1F                /* System Running Priviledged Operating System Tasks  Mode  */
18
19
.set  I_BIT, 0x80                   /* when I bit is set, IRQ is disabled (program status registers) */
20
.set  F_BIT, 0x40                   /* when F bit is set, FIQ is disabled (program status registers) */
21
22
23
.text
24
.arm
25
26
.global  Reset_Handler
27
.global _startup
28
.func   _startup
29
30
_startup:
31
32
# Exception Vectors
33
34
_vectors:       ldr     PC, Reset_Addr
35
                ldr     PC, Undef_Addr
36
                ldr     PC, SWI_Addr
37
                ldr     PC, PAbt_Addr
38
                ldr     PC, DAbt_Addr
39
                nop              /* Reserved Vector (holds Philips ISP checksum) */
40
                ldr     PC, [PC,#-0xFF0]  /* see page 71 of "Insiders Guide to the Philips ARM7-Based Microcontrollers" by Trevor Martin  */
41
                ldr     PC, FIQ_Addr
42
43
Reset_Addr:     .word   Reset_Handler    /* defined in this module below  */
44
Undef_Addr:     .word   UNDEF_Routine    /* defined in main.c  */
45
SWI_Addr:       .word   SWI_Routine      /* defined in main.c  */
46
PAbt_Addr:      .word   UNDEF_Routine    /* defined in main.c  */
47
DAbt_Addr:      .word   UNDEF_Routine    /* defined in main.c  */
48
IRQ_Addr:       .word   IRQ_Routine      /* defined in main.c  */
49
FIQ_Addr:       .word   FIQ_Routine      /* defined in main.c  */
50
                .word   0          /* rounds the vectors and ISR addresses to 64 bytes total  */
51
52
53
# Reset Handler
54
55
Reset_Handler:
56
57
        /* Setup a stack for each mode - note that this only sets up a usable stack
58
        for User mode.   Also each mode is setup with interrupts initially disabled. */
59
60
          ldr   r0, =_stack_end
61
          msr   CPSR_c, #MODE_UND|I_BIT|F_BIT   /* Undefined Instruction Mode  */
62
          mov   sp, r0
63
          sub   r0, r0, #UND_STACK_SIZE
64
          msr   CPSR_c, #MODE_ABT|I_BIT|F_BIT   /* Abort Mode */
65
          mov   sp, r0
66
          sub   r0, r0, #ABT_STACK_SIZE
67
          msr   CPSR_c, #MODE_FIQ|I_BIT|F_BIT   /* FIQ Mode */
68
          mov   sp, r0
69
           sub   r0, r0, #FIQ_STACK_SIZE
70
          msr   CPSR_c, #MODE_IRQ|I_BIT|F_BIT   /* IRQ Mode */
71
          mov   sp, r0
72
          sub   r0, r0, #IRQ_STACK_SIZE
73
          msr   CPSR_c, #MODE_SVC|I_BIT|F_BIT   /* Supervisor Mode */
74
          mov   sp, r0
75
          sub   r0, r0, #SVC_STACK_SIZE
76
          msr   CPSR_c, #MODE_SYS|I_BIT|F_BIT   /* User Mode */
77
          mov   sp, r0
78
79
        /* copy .data section (Copy from ROM to RAM) */
80
                ldr     R1, =_etext
81
                ldr     R2, =_data
82
                ldr     R3, =_edata
83
1:            cmp     R2, R3
84
                ldrlo   R0, [R1], #4
85
                strlo   R0, [R2], #4
86
                blo     1b
87
88
        /* Clear .bss section (Zero init)  */
89
                mov     R0, #0
90
                ldr     R1, =_bss_start
91
                ldr     R2, =_bss_end
92
2:        cmp     R1, R2
93
                strlo   R0, [R1], #4
94
                blo     2b
95
96
        /* Enter the C code  */
97
                b       main
98
99
.endfunc
100
.end

von Jongmun K. (Company: inno) (jmkim519)


Rate this post
useful
not useful
I figure out the problem.

When I change processor Interrupt Enable, it working.

I change Below

first, Stack size change
1
  .set  IRQ_STACK_SIZE, 0X00000004 
2
3
  -->
4
5
  .set  IRQ_STACK_SIZE, 0X00000080

second, IRQ Enable
1
  msr   CPSR_c, #MODE_SYS|I_BIT|F_BIT   /* User Mode */
2
3
  -->
4
5
  msr   CPSR_c, #MODE_USR   /* User Mode */

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.