MQX4.2 MCF52259 Hardwareflow, RTS not working

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

MQX4.2 MCF52259 Hardwareflow, RTS not working

715 Views
carlnormansuret
Contributor V


Hi all,

I need to configure my UART(2) to use RTS flow control on the MCF52259. I can use the UART normally with IO_SERIAL_RAW_IO no problem, but cant get RTS working. I checked PUCPAR and it is set to one indicating primary function of RTS on pin 82 (PUC3).

I tried many experiments, settings, configurations yesterday and this morning. I have posted some simple test code below that hopefully someone can look at and quickly tell me what I have done wrong, or why its not working. I have no experience with hardware flow control really, Ive used it on other projects and it "just worked" so I didnt have to look into it.

//Auto start task

void SDI_Task(void)

{

  uint_32 temp = 0;

  pointer Comm3_IO;

  uint_8 SDI_TX_BUFF[512] = {0};

  //Needs to have 9 bit data, always set low, so I tried this >>

  Comm3_IO = (pointer)fopen("ittyc:", (pointer)(IO_SERIAL_RAW_IO));

//PUCPAR bit 3 becomes set ifi printf PUCPAR or stop debugger and check it...

//9 bit data always low for this application

temp = IO_SERIAL_PARITY_SPACE;

ioctl(Comm3_IO, IO_IOCTL_SERIAL_SET_PARITY, &temp);

  //For a simple test to see if I could just get RTS to change state I tried this >> (this does nothing)

  temp = IO_SERIAL_RTS;

  (void)ioctl(Comm3_IO, IO_IOCTL_SERIAL_SET_HW_SIGNAL, &temp);

  _time_delay(100);

  (void)ioctl(Comm3_IO, IO_IOCTL_SERIAL_CLEAR_HW_SIGNAL, &temp);

  _time_delay(100);

  (void)ioctl(Comm3_IO, IO_IOCTL_SERIAL_SET_HW_SIGNAL, &temp);

  _time_delay(100);

  (void)ioctl(Comm3_IO, IO_IOCTL_SERIAL_CLEAR_HW_SIGNAL, &temp);

  _time_delay(100);

  (void)ioctl(Comm3_IO, IO_IOCTL_SERIAL_SET_HW_SIGNAL, &temp);

  sprintf(SDI_TX_BUFF, "123456789");

  for(;;)

  {

       _time_delay(1000);

       //CTS is manually tied high with a 10K resistor, tried high and low with no change

       //I tried first setting and/or clearing the RTS as above, but still nothing

       fprintf(Comm3_IO, "%s", SDI_TX_BUFF);

  }

}

Tags (1)
0 Kudos
4 Replies

427 Views
carlnormansuret
Contributor V

To start testing i quickly wrote some code which works for a simple test to emulate what I need from RTS.

If MQX's RTS control on ittyc / ttyc is an issue, maybe someone could indicate where in the MQX source I can add two lines marked "//RTS high" and "//RTS low" as this would be fine for my application?

This code works fine for testing, but, I must meet a protocol specification that requires RTS low to happen within 25uS of the final stop bit, and I simply cannot stop my processor like I am below in a loop waiting for the TEMP flag in USR to clear, it would have to be interrupt driven in some way, or, maybe someone has some other ideas?

Comm3_IO = (pointer)fopen("ittyc:", (pointer)(IO_SERIAL_RAW_IO | IO_SERIAL_PARITY_SPACE | IO_SERIAL_STOP_BITS_1));

reg_ptr->GPIO.PUCPAR &= (~0b00000100); //Force to GPIO

reg_ptr->GPIO.DDRUC |= 0b00000100; //Force to output state

reg_ptr->GPIO.PORTUC &= (~0b00000100); //Force to output to low

sprintf(SDI_TX_BUFF, "123456789");

for(;;){

_time_delay(1000);

reg_ptr->GPIO.PORTUC |= 0b00000100; //RTS high

fprintf(Comm3_IO, "%s", SDI_TX_BUFF);

fflush(Comm3_IO);

while((reg_ptr->UART[2].READ.USR & 0x08) == 0);

reg_ptr->GPIO.PORTUC &= (~0b00000100); //RTS low

}

0 Kudos

427 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Carl:

I think you can try the io open flag  "IO_SERIAL_HW_FLOW_CONTROL"

pastedImage_0.png

For see the MQX_IO_User_Guide.pdf for more details

it is located on your installation folder

C:\Freescale\Freescale_MQX_4_2\doc\mqx

Here is an example:

void Main_task(uint_32 initial_data)

{

uint_32 flags=IO_SERIAL_HW_FLOW_CONTROL;

MQX_FILE_PTR pfile1;

MQX_FILE_PTR pfile2;

pfile1 = fopen("ittyc:", NULL);

pfile2 = fopen("ittya:", NULL);

ioctl(pfile1,IO_IOCTL_SERIAL_SET_FLAGS, &flags);

ioctl(pfile2,IO_IOCTL_SERIAL_SET_FLAGS, &flags);

printf("\n Hello World \n");

_time_delay(240000);

fclose(pfile1);

fclose(pfile2);

_mqx_exit(0);

}

Regards

Daniel

0 Kudos

427 Views
carlnormansuret
Contributor V

Thank you Daniel,

I made the following changes to my example based on your example

1. fopen pass NULL

2. Separate call to IO_SERIAL_HW_FLOW_CONTROL using IO_IOCTL_SERIAL_SET_FLAGS

3. changed your printf("\n Hello World \n"); to fprintf(Comm3_IO, "%s", &SDI_TX_BUFF[0]);

Unfortunately no luck. RTS always high. If I call fflush(Comm3_IO); it never returns...

From what you have posted, really you have just pointed out not to pass flags in the fopen call which i thought was ok? I get the same result if I pass flags with fopen or set it after... I did this because MQX example pass flags with fopen. MQX's on examples do this, this is copy and pasted from the example supplied by MQX

rs485_dev = fopen( RS485_CHANNEL, (char const *)IO_SERIAL_HW_485_FLOW_CONTROL );

0 Kudos

427 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Carl:

Have you enabled the macro "BSPCFG_ENABLE_TTYC_HW_SIGNALS" in user_config.h (config/twrmcf52259)?

#define BSPCFG_ENABLE_TTYC_HW_SIGNALS 1

Regards

Daniel

0 Kudos