This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART transmitting interrupt handler

Hello

I am facing a problem in the following code.

code :-

#include "LPC318x.h"
void IRQ_HANDLER(void) __irq
{ PIO_OUTP_SET = 0x7EFFFFFF; PIO_OUTP_SET = 0x7EFFFFFF;
}

int main (void)
{ unsigned int i=0; SYSCLK_CTRL = 0x00000140; HCLKPLL_CTRL = 0x00014024; UARTCLK_CTRL = 0x0F; MIC_ER = 0x000007C0; U5LCR = 0x03; U5CLK = 0x0000020E; UART_CLKMODE = 0x00000550; U5FCR = 0x00; U5IER = 0x07; U3DLL = 27;

while(1) {

U5THR = 0x55; U5THR = 0xAA; }

}

When i enable UART5 interrupt by using MIC_ER interrupt is generated as it should be. But after transmitting the data it jumps to an unusual location
0x000002d4.
But it doesnt go to IRQ handler.
If i don't enable the interrupt using MIC_ER then it executes only while(1) loop.
The main aim of the program is to blink the LED after send data through UART5 as mentioned in the IRQ interrupt handler.

Thank You,

Ankit Thakkar.

Parents
  • sorry for bad code posting.
    you are right that interrupt vector itself is an array of addresses but when it enters into IRQ mode it loads program counter by the starting address of IRQ routine.
    which is LDR instruction.
    I have placed breakpoints on that instructions.
    So when it enters into IRQ mode it should load PC by IRQ routine starting address.
    But it doesn't execute the instruction.
    again i m posting the code where i placed the breakpoints in startup file

    
    Vectors         LDR     PC,Reset_Addr
                    LDR     PC,Undef_Addr
                    LDR     PC,SWI_Addr
                    LDR     PC,PAbt_Addr
                    LDR     PC,DAbt_Addr
                    ;DCD     ||Image$$ER_IROM1$$RO$$Length||+||Image$$RW_IRAM1$$RW$$Length||
                                    DCD             0x4000 ;PHYTEC comment: This hard codes the size
                                                               ;that the secondary bootloader uses to copy
                                                               ;binary software to SDRAM.
    
                    LDR     PC,IRQ_Addr
                    LDR     PC,FIQ_Addr
    
    

    And i placed breakpoints when CPSR is changed when it enters into IRQ mode and loads SP.

    
      Enter IRQ Mode and set its Stack Pointer
                    MSR     CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit
                    MOV     SP, R0
                    SUB     R0, R0, #IRQ_Stack_Size
    
    

    i have placed breakpoints on all the points as shown in the code. but PC doesn't even enter in that code.

Reply
  • sorry for bad code posting.
    you are right that interrupt vector itself is an array of addresses but when it enters into IRQ mode it loads program counter by the starting address of IRQ routine.
    which is LDR instruction.
    I have placed breakpoints on that instructions.
    So when it enters into IRQ mode it should load PC by IRQ routine starting address.
    But it doesn't execute the instruction.
    again i m posting the code where i placed the breakpoints in startup file

    
    Vectors         LDR     PC,Reset_Addr
                    LDR     PC,Undef_Addr
                    LDR     PC,SWI_Addr
                    LDR     PC,PAbt_Addr
                    LDR     PC,DAbt_Addr
                    ;DCD     ||Image$$ER_IROM1$$RO$$Length||+||Image$$RW_IRAM1$$RW$$Length||
                                    DCD             0x4000 ;PHYTEC comment: This hard codes the size
                                                               ;that the secondary bootloader uses to copy
                                                               ;binary software to SDRAM.
    
                    LDR     PC,IRQ_Addr
                    LDR     PC,FIQ_Addr
    
    

    And i placed breakpoints when CPSR is changed when it enters into IRQ mode and loads SP.

    
      Enter IRQ Mode and set its Stack Pointer
                    MSR     CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit
                    MOV     SP, R0
                    SUB     R0, R0, #IRQ_Stack_Size
    
    

    i have placed breakpoints on all the points as shown in the code. but PC doesn't even enter in that code.

Children