AnsweredAssumed Answered

UART interrupt for k65f180m with mqx 4.2

Question asked by annamol alex on Dec 29, 2015
Latest reply on Jan 15, 2016 by annamol alex

Hi,

 

I am trying to enable interrupt on UART lines(ittyd) on the rising edge of reception. So I started off with a hello world program and the following changes were made.

In user_config.h ,

#define BSPCFG_ENABLE_TTYC   1  /* OpenSDA use uart2 */
#define BSPCFG_ENABLE_ITTYC  0
#define BSPCFG_ENABLE_TTYD   0
#define BSPCFG_ENABLE_ITTYD  1

 

In twrk65f180m.h , the following changes were made

#ifndef BSP_DEFAULT_IO_CHANNEL

    #if BSPCFG_ENABLE_ITTYD

        #define BSP_DEFAULT_IO_CHANNEL                        "ittyd:"    /* OpenSDA-COM   polled mode   */

        #define BSP_DEFAULT_IO_CHANNEL_DEFINED

    #else

        #define BSP_DEFAULT_IO_CHANNEL                        NULL

    #endif

 

I am attaching the helloworld.c I wrote. The issue is when I enable the ISR mapping only certain bytes gets displayed on the terminal and when I try entering data via terminal , the ISR never gets hit. Without ISR configuration section, the printf is fine. Is there any example project for the ISR configuration of UART?

Please help me correct the interrupt configuration and ISR so that whenever data is received on the RX pin, the ISR should be hit. Let me know what i am doing wrong with the interrupt section

 

#include <mqx.h>

#include <bsp.h>

#include <fio.h>

 

#if ! BSPCFG_ENABLE_IO_SUBSYSTEM

#error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined non-zero in user_config.h. Please recompile BSP with this option.

#endif

 

#ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED

#error This application requires BSP_DEFAULT_IO_CHANNEL to be not NULL. Please set corresponding BSPCFG_ENABLE_TTYx to non-zero in user_config.h and recompile BSP with this option.

#endif

 

/* Task IDs */

#define HELLO_TASK 5

 

extern void hello_task(uint32_t);

MQX_FILE_PTR uart3;

 

typedef struct my_isr_struct

{

   void                     *OLD_ISR_DATA;

   void      (_CODE_PTR_ OLD_ISR)(void *);

} MY_ISR_STRUCT, * MY_ISR_STRUCT_PTR;

 

 

const TASK_TEMPLATE_STRUCT  MQX_template_list[] =

{

    /* Task Index,   Function,   Stack,  Priority, Name,     Attributes,          Param, Time Slice */

    { HELLO_TASK,   hello_task, 1500,   8,        "hello",  MQX_AUTO_START_TASK, 0,     0 },

    { 0 }

};

 

MY_ISR_STRUCT_PTR  isr_ptr;

 

void uart3_rx_tx_isr()

{

  char ch;

  ch=fgetc(uart3);

  printf("%c",ch);

}

/*TASK*-----------------------------------------------------

*

* Task Name    : hello_task

* Comments     :

*    This task prints " Hello World "

*

*END*-----------------------------------------------------*/

void hello_task

    (

        uint32_t initial_data

    )

{

    (void)initial_data; /* disable 'unused variable' warning */

 

    uart3=fopen("ittyd:",BSP_DEFAULT_IO_OPEN_MODE);

   

    if(uart3==NULL)

      printf("\n uart failed");

    else

    {

      _io_set_handle(IO_STDOUT, uart3);

      printf("\n success\n");

    }

   

//    isr_ptr               =  _mem_alloc_zero((_mem_size)sizeof(MY_ISR_STRUCT));

//    isr_ptr->OLD_ISR_DATA =  _int_get_isr_data(INT_UART3_RX_TX);

//    isr_ptr->OLD_ISR      =  _int_get_isr(INT_UART3_RX_TX);

//

//    /* Native MQX interrupt handling method, ISR is installed into the interrupt vector table in kernel */

//    if(! _int_install_isr(INT_UART3_RX_TX,  (INT_ISR_FPTR)uart3_rx_tx_isr, isr_ptr))

//    {

//        printf("Install interrupt handler to interrupt vector table of MQX kernel failed.\n");

//        _task_block();

//    }

  

//    /* enabling interrupt on uart lines*/

//      _nvic_int_init(INT_UART3_RX_TX, 2, TRUE);  

//      _nvic_int_enable(INT_UART3_RX_TX);  

//      _int_install_isr(INT_UART3_RX_TX, (INT_ISR_FPTR)uart3_rx_tx_isr, uart3);

 

      while(1)

        printf("\nhiii\n");

//    _task_block();

}

Outcomes