UART interrupt for k65f180m with mqx 4.2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART interrupt for k65f180m with mqx 4.2

873 Views
annamol
Contributor IV

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();

}

0 Kudos
3 Replies

506 Views
DavidS
NXP Employee
NXP Employee

Hi,

Sorry to be short as I am on PTO.

Attached is an example of UART isr in the MQX code from a year ago (or so).

Regards,

David

0 Kudos

506 Views
annamol
Contributor IV

Hi,

  • Is it ok to install a new isr for UART in mqx? because I want to parse the data coming via UART and trigger tasks in mqx, also wake up K65 from sleep when UART receives something. Because of which I can't keep on reading using _io_read() or anything else. It can be implemented in bare metal but why not in MQX?
  • I can see data in UART_D register when I tried using iityc and without new isr mapping. But why isn't the RXEDGIF flag not getting set?
  • When I install isr, even printf gets interrupted. if i am printing hello world , it will come something as hell and nothing more
  • Can some one share a working code or at least guide me in the proper way...
  • Hoping for a positive response
0 Kudos

506 Views
annamol
Contributor IV

Hi,

I tried with your code. but the control is not hitting the ISR.

0 Kudos