Can anyone share sample code for ISR based UART in MQX RTOS - i am using K21 for this

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

Can anyone share sample code for ISR based UART in MQX RTOS - i am using K21 for this

1,121 Views
harishveeravall
Contributor I

Currently my requirement is to use UART 2 in K21 as interrupt driven. For this can anyone help me with example code which receives daata from UART byte by byte.

Thanks & Regards,

Harish

Tags (3)
0 Kudos
4 Replies

458 Views
daweiyou
NXP Employee
NXP Employee

Hi Harish:

The Freescale_MQX_4_1\mqx\examples\rs485 demo default use UART interrupt routine;

Which define UART3, you can change follow your HW, the ittyx indicate UART driver use interrupt mode, ttyx indicate UART driver use polling mode.

/* set RS485 output device */

#define RS485_CHANNEL "ittyd:"

Dawei You(尤大为)

458 Views
harishveeravall
Contributor I

Hi Dawei,

In the example code given in rs485, it is waiting @ fread(data_buffer, 1,

18, rs485_dev); and can't we skip this?? and i would rather like to capture

the data as an interrupt, without any function call. Is there any function

of such a kind?? I have noticed on calling fread it is waiting and on

reception of data from UART it is hitting ioserial_int_read () in

serl_int.c file where i can capture actual data and if we donot call fread

it is not hitting this function. Can you please help me resolving this.

Regards,

Harish

On Tue, Aug 5, 2014 at 7:49 PM, Dawei You <admin@community.freescale.com>

0 Kudos

458 Views
daweiyou
NXP Employee
NXP Employee

Hi:

Actually, if I don’t want to change original BSP code, I think we could use new isr to replace old isr, and implement your ISR code here, just like mqx\examples\isr demonstrated:

isr_ptr->TICK_COUNT = 0;

isr_ptr->OLD_ISR_DATA =

intget_isr_data(BSP_TIMER_INTERRUPT_VECTOR);//get back old isr data and save

isr_ptr->OLD_ISR =

intget_isr(BSP_TIMER_INTERRUPT_VECTOR);//get back old isr and save

intinstall_isr(BSP_TIMER_INTERRUPT_VECTOR, new_tick_isr,

isr_ptr);

void new_tick_isr

(

pointer user_isr_ptr

)

{

MY_ISR_STRUCT_PTR isr_ptr;

isr_ptr = (MY_ISR_STRUCT_PTR)user_isr_ptr;

isr_ptr->TICK_COUNT++;//do your code

/* Chain to the previous notifier */

(*isr_ptr->OLD_ISR)(isr_ptr->OLD_ISR_DATA);// call old isr routinue;

}

Dawei You(尤大为);

0 Kudos

458 Views
小勇邹
Contributor II

Hello Dawei,

If I want to do something in the interrupt function,how should I modify the source code?

Do I have to modify the interrupt function in the BSP?

0 Kudos