This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

about pinmux

Other Parts Discussed in Thread: SYSBIOS

if i want to use uart2, then i use the pinmux to get

uart2_rxd_mux0, uart2_txd_mux0,

i want to know, is 

uart2_rxd_mux0, uart2_txd_mux3,

or,

uart_rxd_mux3, uart2_txd_mux0,

is ok?when i select a group of uart,do i need to make the uart2_*xd_mux<n> have the same <n> ?

  • Hi,

    This depends on which pins you want UART2 to come out. Please check Table 4-1 in the AM335X Datasheet Rev. G, which lists pinmux options and modes for each I/O pin.

  • Hi,

    I modify the content udpEcho.c as follows:

    /*

     *    ======== udpEcho.c ========

     */

    /* XDCtools Header files */

    #include <xdc/std.h>

    #include <xdc/cfg/global.h>

    #include <xdc/runtime/Error.h>

    #include <xdc/runtime/Memory.h>

    #include <xdc/runtime/System.h>

    /* BIOS Header files */

    #include <ti/sysbios/BIOS.h>

    #include <ti/sysbios/knl/Clock.h>

    #include <ti/sysbios/knl/Task.h>

     /* NDK Header files */

    #include <ti/ndk/inc/netmain.h>

    #include <ti/ndk/inc/_stack.h>

    /* TI-RTOS Header files */

    #include <ti/drivers/GPIO.h>

    /* Example/Board Header files */

    #include "Board.h"

    #define UDPPORT 1000

    char *LocalIPAddr = "192.168.0.12";

    char *LocalIPMask = "255.255.255.0";

    char *GatewayIP   = "192.168.0.1";

    char *HostName    = "testhost";

    char *DomainName  = "demo.net";

    static  void  NetworkStart();

    static  void  NetworkStop();

    static  void  NetworkIPAddr();

    int NetworkTest()

    {

      int rc;

      CI_IPNET NA;

      CI_ROUTE RT;

      HANDLE hCfg;

      //

      // THIS MUST BE THE ABSOLUTE FIRST THING DONE IN AN APPLICATION!!

      //

      rc = NC_SystemOpen( NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT );

      if( rc )

      {

      System_printf("NC_SystemOpen Failed (%d)\n",rc);

        for(;;);

      }

      //

      // Create and build the system configuration from scratch.

      //

      // Create a new configuration

      hCfg = CfgNew();

      if( !hCfg )

      {

      System_printf("Unable to create configuration\n");

         goto main_exit;

      }

      // We'd better validate the length of the supplied names

      if( strlen( DomainName ) >= CFG_DOMAIN_MAX ||

      strlen( HostName ) >= CFG_HOSTNAME_MAX )

      {

      System_printf("Names too long\n");

        goto main_exit;

      }

      // Manually configure our local IP address

       bzero( &NA, sizeof(NA) );

       NA.IPAddr = inet_addr(LocalIPAddr);

       NA.IPMask = inet_addr(LocalIPMask);

       strcpy( NA.Domain, DomainName );

       NA.NetType = 0;

       // Add the address to interface 1

       CfgAddEntry( hCfg, CFGTAG_IPNET, 1, 0,

       sizeof(CI_IPNET), (UINT8 *) &NA, 0 );

      // Add our hostname

       CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,

       strlen(HostName), (UINT8 *)HostName, 0 );

      // Add the default gateway. Since it is the default, the

      // destination address and mask are both zero (we go ahead

      // and show the assignment for clarity).

       bzero( &RT, sizeof(RT) );

       RT.IPDestAddr = 0;

       RT.IPDestMask = 0;

       RT.IPGateAddr = inet_addr(GatewayIP);

      // Add the route

      CfgAddEntry( hCfg, CFGTAG_ROUTE, 0, 0, sizeof(CI_ROUTE), (UINT8 *) &RT, 0 );

      //

      // Boot the system using this configuration

      //

      // We keep booting until the function returns less than 1. This allows

      // us to have a "reboot" command.

      //

      do

      {

        rc = NC_NetStart( hCfg, NetworkStart, NetworkStop, NetworkIPAddr );

      } while( rc > 0 );

      // Delete Configuration

       CfgFree( hCfg );

      // Close the OS

    main_exit:

         NC_SystemClose();

         return(0);

    }

    static  void  NetworkStart()

    {

    }

    static  void  NetworkStop()

    {

    }

    static  void  NetworkIPAddr()

    {

    }

    /*

     *  ======== udpHandler ========

     *  Echo back all UDP data received.

     *

     *  Since we are using UDP, the same socket is used for all incoming requests.

     */

    Void udpHandler(UArg arg0, UArg arg1)

    {

        SOCKET lSocket;

        struct sockaddr_in sLocalAddr;

        struct sockaddr_in client_addr;

        struct timeval to;

        fd_set readfds;

        int addrlen = sizeof(client_addr);

        int status;

        HANDLE hBuffer;

        IPN LocalAddress = 0;

        int nbytes;

        bool flag = true;

        char *buffer;

        fdOpenSession(TaskSelf());

        lSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

        if (lSocket < 0) {

            System_printf("udpHandler: socket failed\n");

            Task_exit();

            return;

        }

        memset((char *)&sLocalAddr, 0, sizeof(sLocalAddr));

        sLocalAddr.sin_family = AF_INET;

        sLocalAddr.sin_len = sizeof(sLocalAddr);

        sLocalAddr.sin_addr.s_addr = LocalAddress;

        sLocalAddr.sin_port = htons(arg0);

        status = bind(lSocket, (struct sockaddr *)&sLocalAddr, sizeof(sLocalAddr));

        if (status < 0) {

            System_printf("udpHandler: bind failed: returned: %d, error: %d\n",

                    status, fdError());

            fdClose(lSocket);

            Task_exit();

            return;

        }

        /* Give user time to connect with udpSendReceive client app */

        to.tv_sec  = 30;

        to.tv_usec = 0;

        if (setsockopt( lSocket, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ) ) < 0) {

            System_printf("udpHandler: setsockopt SO_SNDTIMEO failed\n");

            fdClose(lSocket);

            Task_exit();

            return;

        }

        if (setsockopt( lSocket, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ) ) < 0) {

            System_printf("udpHandler: setsockopt SO_RCVTIMEO failed\n");

            fdClose(lSocket);

            Task_exit();

            return;

        }

        /* Loop while we receive data */

        while (flag) {

            /*

             * Wait for the reply. Timeout after TIMEOUT seconds (assume UDP

             * packet dropped)

             */

            FD_ZERO(&readfds);

            FD_SET(lSocket, &readfds);

            if (fdSelect(0, &readfds, NULL, NULL, NULL) != 1) {

             status = fdError();

                System_printf("timed out waiting for client\n", status);

                continue;

            }

            nbytes = recvncfrom(lSocket, (void **)&buffer, MSG_WAITALL,

                    (struct sockaddr *)&client_addr, &addrlen, &hBuffer);

            if (nbytes >= 0) {

                /* Echo the data back */

                sendto(lSocket, (char *)buffer, nbytes, 0,

                        (struct sockaddr *)&client_addr, sizeof(client_addr));

                recvncfree( hBuffer );

            }

            else {

             status = fdError();

             if (status == EWOULDBLOCK) {

             System_printf("udpHandler: Waiting for client to send UDP data\n");

             continue;

             }

             else {

                    System_printf(

                        "udpHandler: recvfrom failed: returned: %d, error: %d\n",

                        nbytes, status);

                    fdClose(lSocket);

                    flag = false;

                }

            }

        }

        System_printf("udpHandler stop, lSocket = 0x%x\n", lSocket);

        if (lSocket) {

            fdClose(lSocket);

        }

        fdCloseSession(TaskSelf());

        /*

         *  Since deleteTerminatedTasks is set in the cfg file,

         *  the Task will be deleted when the idle task runs.

         */

        Task_exit();

    }

    /*

     *  ======== netOpenHook ========

     */

    void netOpenHook()

    {

        Task_Handle taskHandle;

        Task_Params taskParams;

        Error_Block eb;

        /* Make sure Error_Block is initialized */

        Error_init(&eb);

        /*

         *  Create the Task that handles UDP "connections."

         *  arg0 will be the port that this task listens to.

         */

        Task_Params_init(&taskParams);

        taskParams.stackSize = 1024;

        taskParams.priority = 1;

        taskParams.arg0 = UDPPORT;

        taskHandle = Task_create((Task_FuncPtr)udpHandler, &taskParams, &eb);

        if (taskHandle == NULL) {

            System_printf("main: Failed to create udpHandler Task\n");

        }

    }

    /*

     *  ======== main ========

     */

    int main(void)

    {

        /* Call board init functions */

        Board_initGeneral();

    Board_initGPIO();

        Board_initEMAC();

        NetworkTest();

        /* Turn on user LED */

        GPIO_write(Board_LED0, Board_LED_ON);

        System_printf("Starting the UDP Echo example\nSystem provider is set to "

                      "SysMin. Halt the target to view any SysMin contents in"

                      " ROV.\n");

        /* SysMin will only print to the console when you call flush or exit */

        System_flush();

        /* Start BIOS */

        BIOS_start();

        return (0);

    }

    I put inside the IP module configuration .cfg modified as follows.After modifying the conflict phenomenon no code before, but found the communication function can not communicate, can not connect. May I ask what is the code I have a problem or add other problems?

    My ultimate goal is to use C code to replace the configuration in the figure below IP module。

  • do you means that i can use uart2 like this,

    uart_rxd_mux3, uart2_txd_mux0

    if my hardware use L18 as txd, A17 as rxd.

    ????

  • AM335X ball L18 in ZCZ package has UART2_TXD in mode 1
    AM335X ball A17 in ZCZ package has UART2_RXD in mode 1