Serial Port ittye on TWR-K53n512

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

Serial Port ittye on TWR-K53n512

448 Views
petershih
Contributor III

HI:

I am working on  TWR-K53n512 with TWR-SER option. I have created the following test code by CW10.5 with MQX 4.0. The serial port works fine on the "ittyd" port. For my project, I need to use "ittye" port. In order to send and receive data with PC, I re-route the A41 and A42 pins on the TWR-K53n512 board to TWR-SER J17 and J19 pin 1. The same source code has been utilized with "ittye", the port doesn't work properly. I am able to set a break point before "write() function, and it looks like the port are receiving correct data. I have tried it on MQX 4.1 and got the same result. I wonder if anyone encounter any similar problem? Please let me know if you have any though. Thanks!

void Main_task(uint32_t initial_data)

{

    void *                fh_ptr;

    int32_t             param;

    uint8_t                serial_buffer[256];

    uint8_t                data_len;

  

    printf("\n Serial Port ITTYE Test \n");

 

    /* Initialize port */ 

    fh_ptr = (void *)fopen("ittye:", (void *) (IO_SERIAL_RAW_IO | IO_SERIAL_NON_BLOCKING));

    if (fh_ptr == NULL)

    {

        printf("cannot open file: ittye\n");                //print to uart0

    }

  

    param = 38400            ;                                //set communication baud

    ioctl(fh_ptr, IO_IOCTL_SERIAL_SET_BAUD, &param);

    param = 8;

    ioctl(fh_ptr, IO_IOCTL_SERIAL_SET_DATA_BITS, &param);    //set eight date bit

    param = IO_SERIAL_STOP_BITS_1;

    ioctl(fh_ptr, IO_IOCTL_SERIAL_SET_STOP_BITS, &param);    //set one stop bit

    param = IO_SERIAL_PARITY_NONE;

    ioctl(fh_ptr, IO_IOCTL_SERIAL_SET_PARITY, &param);        //set none parity bit

  

    while (1)

    {

        data_len = read(fh_ptr,(void *)&serial_buffer,0xFFFF);        //read() here is non-blocking function

        if(data_len != 0)

        {

            write(fh_ptr,(void *)serial_buffer, data_len);

            fflush(fh_ptr);    //empty queue

            _time_delay(1);

        }

    }

   _mqx_exit(0);

}

pastedImage_12.png

The green color shows the data sent from PC to TWR-K53n512.

The yellow color shows the data sent from TWR-K53n512 back to PC.

Peter

0 Kudos
2 Replies

243 Views
soledad
NXP Employee
NXP Employee

Hi,

Please check using the user_config.h and twrk53n512.h files attached and let me know if this helps!!!


Have a great day,
Regards
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

243 Views
Wlodek_D_
Senior Contributor II

Hello,

Thank you for your post, however please consider moving it to the right community place (e.g. MQX Software Solutions ) to get it visible for active members.

For details please see general advice Where to post a Discussion?

Thank you for using Freescale Community.

0 Kudos