Hi RadekS,
Thank you.
Without MQX, UART1 is working fine with baudrate 115200 in polling mode. We are able to send AT commands from freescale and received response from BT43h.
Now we are facing issue with UART1 using MQX RTOS. We did the required changes for UART1 to work in interrupt mode in user_config file and init_gpio file.
i.e.,
- #define BSPCFG_ENABLE_ITTYB 1
- Following GPIO's used for UART1 (Muxing to Alt.3 ).
- UART1_TX - PTE0
- UART1_RX- PTE1
- UART1_CTS_b- PTE2 - floated
- UART1_RTS_b- PTE3 - floated
- baudrate 115200
Attached the sample code for reference.
#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 WORLD_TASK 6
void world_task(uint32_t);
const TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
/* Task Index, Function, Stack, Priority, Name, Attributes, Param, Time Slice */
{ WORLD_TASK, world_task, 1000, 9, "world", MQX_AUTO_START_TASK, 0, 0 },
{ 0 }
};
#define RS232CHANNEL "ittyb:" //DES output via the OSBDM interface
MQX_FILE_PTR rs232_dev;
volatile byte ubUDR;
void uart1_rx_tx_isr(INT_ISR_FPTR user_isr_ptr)
{
/* Get the device registers */
UART_MemMapPtr sci_ptr = _bsp_get_serial_base_address (1); //DES get base address for UART1
ubUDR = sci_ptr->S1; //DES read status register. Part of two step process to clear the interrupt flag.
ubUDR = sci_ptr->D; //DES get the character (Receiving 0x00 everytime)
}
/*TASK*-----------------------------------------------------
*
* Task Name : world_task
* Comments :
* This task creates hello_task and then prints " World ".
*
*END*-----------------------------------------------------*/
void world_task
(
uint32_t initial_data
)
{
_task_id hello_task_id;
uint32_t baud=115200;
char data_bufferTR[] = {"AT+AB Reset\r\n"};
_mqx_int err;
/* Init_GPIO(); */
PORTE_PCR1 = (0|PORT_PCR_MUX(3)); // UART1_RX
PORTE_PCR0 = (0|PORT_PCR_MUX(3)); // UART1_TX
PORTE_PCR2 = (0|PORT_PCR_MUX(3)); // UART1_CTS_b
PORTE_PCR3 = (0|PORT_PCR_MUX(3)); // UART1_RTS_b
GPIOE_PDDR|=GPIO_PDDR_PDD( GPIO_PIN_N(0 )); // output
GPIOE_PDIR |= GPIO_PDIR_PDI(GPIO_PIN_N(1)); // input
rs232_dev = fopen( RS232CHANNEL, BSP_DEFAULT_IO_OPEN_MODE );
err = ioctl(rs232_dev,IO_IOCTL_SERIAL_SET_BAUD, &baud);
_nvic_int_init(INT_UART1_RX_TX, 2, TRUE);
_nvic_int_enable(INT_UART1_RX_TX);
_int_install_isr(INT_UART1_RX_TX, (INT_ISR_FPTR)uart1_rx_tx_isr, rs232_dev);
err = ioctl(rs232_dev,IO_IOCTL_SERIAL_GET_BAUD, &baud); // to confirm the baudrate
write(rs232_dev, data_bufferTR, strlen(data_bufferTR)); // uart rx isr is triggered
}
/* EOF */