hi,
We are using MK61FN1M0VMJ12 processor for our application, to create BSP for this processor we used processor expert driver suite and generated code for BSP. As suggested in BSP porting guide we took the required functions from generated cpu.c and cpu.h and merged in Cloned BSP (K60F120M).
After merging, we tested the BSP by creating one MQX task and written code for enabling and disabling GPIO, till now everything works fine.
Now we are trying to send/receive data from UART0 (Alt4 muxing pins PTF17 an PTF18), using driver code uart.c and uart.h files and methods "uart_init", "uart_putchar" and "uart_getchar", but data received is not correct. Tried adjusting the core clock and baud rate also. Please suggest, if any settigns we need to do in processor expert driver suite for UART0.
Note: We tested the MK61FN1M0VMJ12, UART0 is working with same uart driver files without MQX.
Please let me know if any details required.
Thanks in advance...
解決済! 解決策の投稿を見る。
Hi RadekS,
Thanks for your suggestions...!
We already tried all the changes you suggested.
Actually the problem was with the baudrate, We were trying for a slower baudrate, which is not supported by UART0.
Found this when I tried to configure UART0 from PEx driver Suite. After increasing baudrate, UART0 is working.
Thanks
It seems that some part of MQX interacts with selected pins or rather there is some issue with interrupts.
#define BSPCFG_ENABLE_TTYA 1
#define BSPCFG_ENABLE_ITTYA 0
And #define BSP_DEFAULT_IO_CHANNEL anything else than "ttya:" or "ittya:"
followed by command
_bsp_int_init(vector, priority, subpriority, enable);
Note: When vector table is in flash, you can install your kernel isr into the hw vector table in vectors.c in BSP project.
Note: Of course, since MQX do not know about this interrupt, you cannot call MQX API in such routines.
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!
-----------------------------------------------------------------------------------------------------------------------
Hi RadekS,
Thanks for your suggestions...!
We already tried all the changes you suggested.
Actually the problem was with the baudrate, We were trying for a slower baudrate, which is not supported by UART0.
Found this when I tried to configure UART0 from PEx driver Suite. After increasing baudrate, UART0 is working.
Thanks
Hi,
thank you very much for let us know the root cause.
I wish you good luck in the future development.
Have a great day,
RadekS
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.,
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 */
Hi,
could you please explain, why did you combine MQX serial driver with your own ISR routine?
Interrupt serial driver already contains its own ISR routine and you simply cut it from use by:
_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);
It is like you try run without legs.
Interrupt driven serial driver needs own ISR routine for both RX and TX communication. So, you probably even did not transfer your AT command. Therefore you cannot expect any reply from modem.
Could you please try serial driver without your own ISR routine?
From reading modem’s response you can use function read() similar way how you already used function write().
Serial driver already contains receive buffer, therefore you should not miss any of characters. Size of this buffer could be driven by definition BSPCFG_SCI1_QUEUE_SIZE. Default value is 64 chars.
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!
-----------------------------------------------------------------------------------------------------------------------
Hi RadekS,
Yes, I observed in oscilloscope also, AT command is not getting transferred.
I am new to MQX, Could you please share any example which explains UART ISR for Rx and Tx communication?
Thanks in advance..!
Hi,
MQX serial driver is installed to system in BSP code (init_bsp.c) on base of your definitions in user_config.h, like:
#define BSPCFG_ENABLE_ITTYB 1
Note: it has no sense to install pooled and interrupt driver for one interface. So, definition for ttyx should be 0 when ittyx is 1 and opposite.
If you use definition #define BSP_DEFAULT_IO_CHANNEL "ittyb:", interrupt serial driver for UART1 will be installed automatically as default console and you can use directly printf() function in your code.
If you want use different UART than default console, you should use fopen() for initialize handler to this channel.
After that you can simply use read(), write().
You don’t need to take care about interrupt routine; this is part of driver’s job.