Coldfire 5208 UART interrupt

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Coldfire 5208 UART interrupt

1,081件の閲覧回数
Tsai
Contributor I

Hello all.

I am trying to connect a PC and coldfire 5208 EVB by using UART module (it is interrupt-driven) in coldfire 5208.

The message received from the PC to coldfire 5208 is not correct.

The problem is PC runs in the interrupt service routine and can not go back to main function.

The interrupt source number of UART0 in coldfire 5208 is 26, and its interrupt vector number is 90.

My IDE is codewarrior 7.0.

The following is my code and please help me check it. Thank you!

 

 

 

In exceptions.c:

...

extern void COMM_INT(void);

...

asm_exception_handler,           /*  89 (0x164) Device-specific interrupts */
COMM_INT,                                  /*  90 (0x168) Device-specific interrupts */
asm_exception_handler,          /*  91 (0x16C) Device-specific interrupts */

 

--------------------------COMM_INT function-----------------------------------------------------------------------------------------------------------------

 

void COMM_INT(void)
{

   MCF_INTC_IMRL = 0xFBFFFFFF;

       if ((MCF_UART0_UISR & 0x02) == 2){
         while ((MCF_UART0_USR & MCF_UART_USR_RXRDY)){
            if (Rxidx >40) Rxidx = 0;
               COM_RX_buf[Rxidx] = MCF_UART0_URB;

               Rxidx++;  
              asm
            {
                move.w        #0x2300,sr
            }
         MCF_INTC_IMRL = 0xFBFFFFFF;
         MCF_INTC_CLMASK = 0x03;
         MCF_INTC_SLMASK = 0x03;
      }
      
    }
    RX1_DATA_RDY=1;

}

 

-----------------------------------------------------------interrupt initialization-----------------------------------------------------------------------------

 

void Ini_int_UART(void)
{
    MCF_INTC_IMRH = 0xffffffff;
    MCF_INTC_IMRL = 0xFBFFFFFF;
    MCF_INTC_ICR26 = 4;
    MCF_INTC_ICONFIG = 0x1020;
    MCF_INTC_CLMASK = 0x03;
    MCF_INTC_SLMASK = 0x03;
    /* Interrupt
     * Don't Mask all UART interrupts
     */
    MCF_UART_UIMR(0) = 0x02;
}

 

--------------------------------------------------UART initialization ----------------------------------------------------

 

void uart_init(int channel, unsigned long systemClockKHz, unsigned long baudRate)
{
    /*
     * Initialize UART for serial communications
     */

    register uint16 ubgs;

    /*
     * Reset Transmitter
     */
    MCF_UART_UCR(channel) = MCF_UART_UCR_RESET_TX;

    /*
     * Reset Receiver
     */
    MCF_UART_UCR(channel) = MCF_UART_UCR_RESET_RX;

    /*
     * Reset Mode Register
     */
    MCF_UART_UCR(channel) = MCF_UART_UCR_RESET_MR;

    /*
     * No parity, 8-bits per character
     */
    MCF_UART_UMR(channel) = (0
        | MCF_UART_UMR_PM_NONE
        | MCF_UART_UMR_BC_8 );

    /*
     * No echo or loopback, 1 stop bit
     */
    MCF_UART_UMR(channel) = (0
        | MCF_UART_UMR_CM_NORMAL
        | MCF_UART_UMR_SB_STOP_BITS_1);

     //MCF_UART_UMR(channel) = (0|MCF_UART_UMR_RXIRQ);
     
    /*
     * Set Rx and Tx baud by SYSTEM CLOCK
     */
    MCF_UART_UCSR(channel) = (0
        | MCF_UART_UCSR_RCS_SYS_CLK
        | MCF_UART_UCSR_TCS_SYS_CLK);

    MCF_UART_UIMR(0) = 0x02;
    

    /*
     * Calculate baud settings
     */
    ubgs = (uint16)((systemClockKHz * 1000)/(baudRate * 32));

#if UART_SUPPORT_TYPE==UART_DIVIDER || UART_SUPPORT_TYPE == UART_5407
    MCF_UART_UDU(channel) = (uint8)((ubgs & 0xFF00) >> 8);
    MCF_UART_UDL(channel) = (uint8)(ubgs & 0x00FF);
#else /* UART_SUPPORT_TYPE!=UART_DIVIDER */
    MCF_UART_UBG1(channel) = (uint8)((ubgs & 0xFF00) >> 8);
    MCF_UART_UBG2(channel) = (uint8)(ubgs & 0x00FF);
#endif /* UART_SUPPORT_TYPE==UART_DIVIDER */

    /*
     * Enable receiver and transmitter
     */
    MCF_UART_UCR(channel) = (0
        | MCF_UART_UCR_TX_ENABLED
        | MCF_UART_UCR_RX_ENABLED);
}

ラベル(1)
0 件の賞賛
1 返信

396件の閲覧回数
Tsai
Contributor I

Sorry.

The problem is PC(program counter) runs in the interrupt service routine(exceptions.c) and can not go back to main function.

0 件の賞賛