Hey ,every one I find a problem about interrupt uart in MQX .I use K60 microcontroller.
Now I can receive data from ISR. but when I send bytes to Computer. I just receive one byte in Computer. even if I send one byte follow one byte .I also just can receive only the first byte. Someone can help me?
After I install my uart ISR . I can not disable it . I have try use _int_disable(); But it does not work.
Below is my code:
void world_task
(
uint_32 initial_data
)
{
MY_ISR_STRUCT_PTR uart_isr_ptr;
unsigned char return1s;
_task_id hello_task_id;
upload_dev = fopen( "ittyd:", BSP_DEFAULT_IO_OPEN_MODE ); //BSP_DEFAULT_IO_OPEN_MODE IO_SERIAL_RAW_IO
uint_32 baud=9600;
// _kuart_int_enable();
return1s = _bsp_serial_io_init(3, (IO_PERIPHERAL_PIN_MUX_ENABLE|IO_PERIPHERAL_CLOCK_ENABLE));
if(return1s == MQX_OK)
{
printf("OK");
}
_int_install_isr(INT_UART3_RX_TX,UART4_RX_ISR,upload_dev);
_task_block();
}
/* EOF */
uint32_t g_UART_ISR_buffer[40]; //
void UART4_RX_ISR( pointer user_isr_ptr)
{
unsigned char Redata;
int itemp;
UART_MemMapPtr sci_ptr = UART3_BASE_PTR;
if ((sci_ptr->S1 & UART_S1_RDRF_MASK)==0) goto UART4_RX_ISR_End;
Redata = sci_ptr->D; //?????????
if(CreateFrame(Redata)!=0)
{
//_lwevent_set(&lwevent_group,Event_UART4_ReData);
}
UART4_RX_ISR_End: ;
}
Solved! Go to Solution.
I suppose that you want use ittyd: as serial interface out of default console. Correct?
In that case you should decide whether you will use MQX uart driver or you will write your own.
In your code I see combination of both these approaches. You installed MQX driver but you changed drivers ISR.
If you want use MQX driver, please enable this interface in user_config.h file, use fopen, fread, fwrite for communication over serial driver. Interrupt UART driver already contains buffer for received data. Size of this buffer could be change by definition #define BSPCFG_SCI3_QUEUE_SIZE 64, where this number could be in range 0..256 (64bytes is default size)
If you want use your own serial driver (probably some low level or generated by PE), please disable this interface user_config.h file, don’t use fopen, fread, fwrite when your driver is not posix and install ISR out of MQX by command int_install_kernel_isr() and _bsp_int_init(). This way you will have full control on your serial interface.
Note: In that case please check also init_gpio.c file whether serial interface pins are not in collision with any other IOs.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I suppose that you want use ittyd: as serial interface out of default console. Correct?
In that case you should decide whether you will use MQX uart driver or you will write your own.
In your code I see combination of both these approaches. You installed MQX driver but you changed drivers ISR.
If you want use MQX driver, please enable this interface in user_config.h file, use fopen, fread, fwrite for communication over serial driver. Interrupt UART driver already contains buffer for received data. Size of this buffer could be change by definition #define BSPCFG_SCI3_QUEUE_SIZE 64, where this number could be in range 0..256 (64bytes is default size)
If you want use your own serial driver (probably some low level or generated by PE), please disable this interface user_config.h file, don’t use fopen, fread, fwrite when your driver is not posix and install ISR out of MQX by command int_install_kernel_isr() and _bsp_int_init(). This way you will have full control on your serial interface.
Note: In that case please check also init_gpio.c file whether serial interface pins are not in collision with any other IOs.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Do you have an example of how to use UART interrupts? I'm using this code to install the ISR
_nvic_int_init(INT_UART4_RX_TX, 2, TRUE);
_nvic_int_enable(INT_UART4_RX_TX);
_int_install_isr(INT_UART4_RX_TX, uart4_rx_tx_isr, port);
I'm doing that in my initialization routine along with other things. Immediately after those three lines, I perform a fwrite and I can see that the uart4_rx_tx_isr function is being called after the first byte is sent and then my applications crashes and the MCU restarts.
Hey , Radeks.Thank you so much for ur answer. I will use your function to modify my code . If I have any question . I will chat with you again .Thank you .But I want to ask u how to know how many bytes in buffer that I can read. Because I want to read data from buffer. But I dont know how many. Do you know which function can tell me how many bytes data in buffer.
Thank you again.
I would like to propose two basic options:
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------