AnsweredAssumed Answered

K60 UART Problems

Question asked by David Tietz on Jan 11, 2013
Latest reply on Jan 17, 2013 by David Tietz

I am having problems initializing the UARTs on the K60 using MQX 3.8 and CW 10.3.

 

I had a “daughter board” made to plug into the tower system that gives us access to the UARTs I am trying to use. For this project I am using UART1, UART3, UART4, and UART5. All the UARTs seem to work fine on the transmit side.

 

I modified the twrk60n512.h file and the user_config.h file to enable the interrupt version of ttyb, ttyc, etc. in the MQX files. I then recompiled all projects.

 

Below is a snippet of my code to help explain what I am doing.

 

    uart_ptr1 = fopen("ittyb:", BSP_DEFAULT_IO_OPEN_MODE);

    uart_ptr3 = fopen("ittyd:", BSP_DEFAULT_IO_OPEN_MODE);

    uart_ptr4 = fopen("ittye:", BSP_DEFAULT_IO_OPEN_MODE);

    uart_ptr5 = fopen("ittyf:", BSP_DEFAULT_IO_OPEN_MODE);

   

   

    if(uart_ptr1 == NULL)

    {

        write(uart_ptr3,(pointer)"UART1: failed to open", 20);   

    }

   

    if(uart_ptr3 == NULL)

    {

        write(uart_ptr3,(pointer)"UART3: failed to open", 20);   

    }   

   

    if(uart_ptr4 == NULL)

    {

        write(uart_ptr3,(pointer)"UART4: failed to open", 20);   

    }

   

    if(uart_ptr5 == NULL)

    {

        write(uart_ptr3,(pointer)"UART5: failed to open", 20);    

    }

 

    write(uart_ptr1,(pointer)"Hello World:UART1\n\r", 17);    // write char to uart1   (works fine)

    write(uart_ptr3,(pointer)"Hello World:UART3\n\r", 17);    // write char to uart3   (works fine)

    write(uart_ptr4,(pointer)"Hello World:UART4\n\r", 17);    // write char to uart4     (works fine)

    write(uart_ptr5,(pointer)"Hello World:UART5\n\r", 17);    // write char to uart5   (works fine)

   

   

    p3_scm_imm();    //Checking to see if there are any new scan or non-scan messages to process

           

    while(1)

    {

        while(fstatus(uart_ptr1))

        {

            ch = fgetc(uart_ptr1);

            write(uart_ptr1,(pointer)ch, 1);   

        }

 

        while(fstatus(uart_ptr3))

        {

            ch = fgetc(uart_ptr3);

            write(uart_ptr3 ,(pointer)ch, 1);   

        }

        while(fstatus(uart_ptr4))

        {

            ch = fgetc(uart_ptr4);

            write(uart_ptr4,(pointer)ch, 1);   

        }

        while(fstatus(uart_ptr5))

        {

            ch = fgetc(uart_ptr5);

            write(uart_ptr5,(pointer)ch, 1);   

        }

}


 

In my only task that I call, I send out a “Hello World” from each port. That works okay. The problem lies in the receiving side of things. After initializing the ports, I sit and wait for data to be received. UART3 appears to work fine, but with the exact same code, I cannot seem to get UART1, UART4, or UART5 to work (see above). The code should just echo back out what is received.

 

Is there something I'm missing in the initialization of the other ports that had already been done to the default port (UART3 – ttyd)?

Outcomes