MCF52259, MQX RTOS 3.6: UART1 Not working

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

MCF52259, MQX RTOS 3.6: UART1 Not working

1,198 Views
shriramgaur
Contributor II

Hello, 

Unable to transmit or receive over UART1 - We've custom board, based on MCF52259EVB and using MQX RTOS Version 3.6; Development environment is on CodeWarrior IDE 7.2. We are using UART1 (for Debug console) and UART2 (for slave communication). UART0 is not available to use.

The problem here is UART1 (Tx1 pin 62) is not transmitting any data, whereas UART2 (Tx2 pin 101) works fine for exact same configuration.

I've verified physical connectivity for UART1 port pin (Tx Pin 62). It remains high all the time. Also, If I try to toggle port pin after configuring it as GPIO, it works fine as GPIO. 

Steps followed for UART 1 and UART2 configurations are: 

  1. Enable BSPCFG_ENABLE_TTYB & BSPCFG_ENABLE_TTYC in D:\Freescale MQX 3.6\config\m52259evb\user_config.h
  2. Enable BSPCFG_ENABLE_TTYB & BSPCFG_ENABLE_TTYC in \Freescale MQX 3.6\mqx\source\bsp\m52259evb\m52259evb.h 
  3. Modify BSP_DEFAULT_IO_CHANNEL "ttya:" -> "ttyb:" in \Freescale MQX 3.6\mqx\source\bsp\m52259evb\m52259evb.h

After these changes recompiled bulid_libs.mcp. With these changes, my UART2 works fine, however, UART1 never worked. I also confirmed with my colleagues and according to them, it never worked. 

I also tried to enable ITTYB but it still doesn't work. whereas UART2 works in all configuration (TTYC or ITTYC) without any trouble. 

 

Here is extract of my code: 

/*************************************************************************
* Description: Initialize UART1 for debug console.
**************************************************************************/

#define UART1_BAUD_RATE 9600

pointer UART1_Handle;

uint_8 Init_UART1_Dbg(void)
{

uint_32 baud_rate, temp = 0;

UART1_Handle = (pointer)fopen("ttyb:", (pointer)(IO_SERIAL_RAW_IO));  //tried with default settings, doesn't work

if (UART1_Handle == NULL)
{
return 30;
}

baud_rate = UART1_BAUD_RATE ;

if (ioctl(UART1_Handle, IO_IOCTL_SERIAL_SET_BAUD, &baud_rate) != IO_OK)
{
return 60;
}
_io_set_handle(IO_STDOUT, UART1_Handle);
printf("This is printed to the other device\n");

return 100;
}

 

#define UART2_BAUD_RATE 9600

pointer UART2_Handle;

uint_8 Init_UART2(void)
{

uint_32 baud_rate, temp = 0;

UART2_Handle = (pointer)fopen("ttyc:", (pointer)(IO_SERIAL_RAW_IO));

if (UART2_Handle == NULL)
{
return 25;
}

baud_rate = UART2_BAUD_RATE ;

if (ioctl(UART2_Handle, IO_IOCTL_SERIAL_SET_BAUD, &baud_rate) != IO_OK)
{
return 50;
}
//_io_set_handle(IO_STDOUT, UART2_Handle);
//printf("This is printed to the other device\n");

return 200;
}

/***************** start up task ******************/
void startup_task(uint_32 initial_data)
{

uint_32 led_on_time = 0, led_off_time = 0;

LED_Init();

//Test_UART1_TX_Pin_Init(); //init UART1 tx pin as gpio, toggles fine

led_on_time = Init_UART1_Dbg();
led_off_time = Init_UART2();


while(1)
{

LED_control(ON); //set led status on
fprintf(UART1_Handle, "UART1 - LED ON\r\n");
_time_delay_ticks(2);
fprintf(UART2_Handle, "UART2 - LED ON\r\n");
_time_delay_ticks(led_on_time);

//Toggle_uart1_tx_pin(TRUE); //works fine


LED_control(OFF); //set led status off
fprintf(UART1_Handle, "UART1 - LED OFF\r\n");
_time_delay_ticks(2);
fprintf(UART2_Handle, "UART2 - LED OFF\r\n");
_time_delay_ticks(led_off_time);
//Toggle_uart1_tx_pin(FALSE); //works fine
} //end while 1

} //end startup task

Here are summary of trials:

  • Port pin toggled successfully - Port UB - verified on tx, rx and cts pin
  • Tried interrupt mode exactly similar to UART2, did not work. port pin remains high all the time
  • Tried polled mode - did not work. port pin remains high all the time
  • Tried default IO = ttyb - did not work. port pin remains high all the time
  • Tried default IO = ttya, and UART1 as normal UART (configuration similar to UART2, which is working), did not work. Port pin remains high all the time
  • check secondary functionality - I2C_SCL1 - I2C1 is disabled
  • check Tertiary functionality - Not available
  • check Quaternary functionality - Port UB (general purpose IO) - works fine (checked by toggling GPIO pins)

 

I've started to think,

a. Could it be RTOS configuration issue which is not enabling UART1 ?

b. MCU issue in UART1 ?

I couldn't find anything in MQX RTOS release notes regarding UART issues, nor the MCU errata have any mention of it.

What could be the missing link here and why UART1 is behaving differently than UART2 ?

Can anyone suggest what am I missing here? Is it RTOS configuration issue, MCU issue or something else ?

Appreciate any help on it.  

Thanks,

Shriram 

0 Kudos
5 Replies

1,153 Views
shriramgaur
Contributor II

Hello Mike, 

Tried with RTOS ver 3.7, uart1 still doesn't work. 

Question: when I tried to create project for testing through PE expert, it took pin 24/25 as default UART1 pins, whereas UART1 primarily is on pin 62, 63. I tried to dig into RTOS code but not positive on the settings here. Is there any default setting which I can look into ?

 

Thanks,

Shriram 

0 Kudos

1,178 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi, 

I checked the system supporting records about M52259EVB UART1 MQX example demo, please check attached code as an example.

Wish it helps.

Mike

 

0 Kudos

1,170 Views
shriramgaur
Contributor II

Hello Mike,

Thank you for the response. I tried with your supplied code but problem still persist. No data on UART1 tx line. 

However, there is one observation: When I read back parameters of UART1: 

  1. Before initialization: baud rate = 115200, data bit = 8, stop bits = 7, parity = 3326
  2. After setting new parameters (set ioctl): baud rate = 9600, data bit = 8, stop bits = 7, parity = 0

look at stop bit value: it's returning 7, why ? (Configuration issue: able to set baud, parity but not stop bit ). 

PS: My dev env uses MQX RTOS Version 3.6, CodeWarrior 7.2

Thanks,

Shriram 

0 Kudos

1,161 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Could you try to update MQX to V3.7 with CodeWarrior for ColdFire V7.2?

I post below code for your reference:

1> How to modify UART0 buad rate:
Please add below codes to your to modify UART0 baud rate from 115200 to 19200:
pointer fh_ptr;
uint_32 setbaud = 19200;
fh_ptr = (pointer)fopen("ttya:", BSP_DEFAULT_IO_OPEN_MODE);
ioctl(fh_ptr,IO_IOCTL_SERIAL_SET_BAUD,&setbaud);

2>Modify M52259EVB default serial port from UART0 to UART1:
need to open and select ;
change #define BSPCFG_ENABLE_TTYB from 0 to 1;
change BSP_DEFAULT_IO_CHANNEL related part:
#ifndef BSP_DEFAULT_IO_CHANNEL
#if BSPCFG_ENABLE_TTYB
#define BSP_DEFAULT_IO_CHANNEL "ttyb:"
#define BSP_DEFAULT_IO_CHANNEL_DEFINED
#else
#define BSP_DEFAULT_IO_CHANNEL NULL
#endif
#endif
Then UART1 will replace UART0 as default serial terminal port.

A short code for using UART1:
const uint_8 SyncCmd[] = {0xAA, 0x0D, 0x00, 0x00, 0x00, 0x00};
uint_8 recvBuffer[512];
FILE_PTR uart1_ptr;
uart1_ptr = fopen("ittyb:", 0x00);
_io_write(uart1_ptr, (pointer)&SyncCmd[0], sizeof(SyncCmd)); _io_read(uart1_ptr, &recvBuffer[0], 12);

 

Wish it helps.

Mike

0 Kudos

1,118 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Q1 : where can I find schematic of MCF52259 EVB board ? I searched online, couldn't locate
TS: Please check attached M52259EVB schematics.


Q2: when I tried to create project for testing through PE expert, it took pin 24/25 as default UART1 pins, whereas UART1 primarily is on pin 62, 63.
I tried to dig into RTOS code but not positive on the settings here. Is there any default setting which I can look into ? Thanks,Shriram
TS: M52259EVB is using pin 62 as UART1_TXD, pin 63 as UART1_RXD.
Related code located at <gpio_init.c>'s _bsp_serial_io_init function.
I checked the MQX V3.7 for M52259EVB is using pin 62 as UART1_TXD.

Thanks for the attention.

Mike

0 Kudos