AnsweredAssumed Answered

Serial Port ittye on TWR-K53n512

Question asked by PETER SHIH on Mar 26, 2014
Latest reply on Apr 28, 2014 by soledad

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);

}

 

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

Outcomes