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

Hard fault in UART IRQHandler when using Keil RTX

Hi,
I have just started using Keil RTX and I am a newbie.
Without RTX, I initialize my uart in the main() and then recive data in IRQHandler.
But after I tried my UART with RTX I get a hard fault inside of IRQHandler.
This is my code to initialize and use UART1 (I don't copy all of the codes, all of the variables are defined and there is no compiling error):


void UART1_IRQHandler(void) {

        uint32_t intsrc, tmp;
        char last_received_char;
        /* Determine the interrupt source */
    intsrc = UART_GetIntId(UART_1);
    tmp = intsrc & UART_IIR_INTID_MASK;


        // Receive Data Available
    if (tmp & UART_IIR_INTID_RDA)
    {
                        printf("iq\n"); /// I see this in debug window

       isr_evt_set(0x0001, cam_id);     // Send Event Flag to task
                        printf("EV\n"); /// I don't see this in debug window!!
    }

   NVIC_ClearPendingIRQ(UART1_IRQn);   // Clear Interrupt




}

void UART1_Init1(){


        UART_CFG_Type UART1_CFG;
        UART_FIFO_CFG_Type UART1_FIFO_CGF;


        UART1_CFG.Parity=UART_PARITY_NONE;
        UART1_CFG.Baud_rate=38400;
        UART1_CFG.Databits=UART_DATABIT_8;
        UART1_CFG.Stopbits=UART_STOPBIT_1;

        //UART_FIFOConfigStructInit(&UART1_FIFO_CGF);
        //UART_FIFOConfig(UART_1,&UART1_FIFO_CGF);

        PINSEL_ConfigPin(0,15,1);
        PINSEL_ConfigPin(0,16,1);

        UART_Init(UART_1, &UART1_CFG);
        UART_TxCmd(UART_1,ENABLE);

        UART_IntConfig(UART_1, UART_INTCFG_RBR, ENABLE);
       /* Enable UART line status interrupt */
  UART_IntConfig(UART_1, UART_INTCFG_RLS, ENABLE);
        //UART_IntConfig(UART_1,UART_INTCFG_RBR,ENABLE);

        NVIC_SetPriority(UART1_IRQn, 1);
        NVIC_EnableIRQ(UART1_IRQn);


}

__task void UART1_SerialCall() {

                char Ch;
        OS_RESULT result;

        while (1) {



                        result=os_evt_wait_or(0x0001, 0xffff);
        if (result != OS_R_TMO) {

                //// ...... get char and do some jobs
        }


        }
 }



__task void init (void) {

        static U64 stk_clock[2000/8];
        static U64 stk_photo[2000/8];
        static U64 stk3[2000/8] __attribute__((at(0xA0000100)));;


  GUI_Init();



                UART1_Init1(); //38400

                MainTask();



        os_tsk_create_user(_GUI_Task,10,&stk3,sizeof(stk3));

        os_tsk_create_user(clock,9,&stk_clock,sizeof(stk_clock));   /* start task clock                 */


        cam_id = os_tsk_create(UART1_SerialCall,4); // UART1 task


        os_tsk_create_user(photo,9,&stk_photo,sizeof(stk_photo));   /* start task photo */

  os_tsk_delete_self ();
}


int main (void) {

 unsigned int cclk = CLKPWR_GetCLK(CLKPWR_CLKTYPE_CPU);
 SDRAM_32M_16BIT_Init();
debug_frmwrk_init();


  os_sys_init_user(init,1,&stk_ini,sizeof(stk_ini));    /* Initialize RTX and start init */
  for (;;);
}

Parents Reply Children
No data