1
\$\begingroup\$

I'm using the Zybo board. I have a design like the following one:

enter image description here

On the SDK, I have a code like the following one to handle data exhange between PS Uart0 (where the SEM signals are connected, monitor_rx and monitor_tx) and the device's UART1 (that is responsible for stdin,stdout transmission), give access to ICAP for SEM initialization etc:

int main()
    {


    XUartPs xuartps0;
    XUartPs_Config *xuartps_config0;
    XUartPs xuartps1;
    XUartPs_Config *xuartps_config1;
    int status;
    int status1 =2;
    /*SETUP*/
    init_platform();
    Delay(200);
    init_GPIO();
    //init_TIMER();
    Delay(200);
    init_Dcfg();
    //Delay(200);



    XUartPsFormat xuartps0_format;
    XUartPsFormat xuartps1_format;



    xuartps_config0 = XUartPs_LookupConfig(XPAR_XUARTPS_0_DEVICE_ID);
      if (xuartps_config0 == NULL) {
        return XST_FAILURE;
      }
      XUartPs_ResetHw(xuartps_config0->BaseAddress);
      status = XUartPs_CfgInitialize(&xuartps0, xuartps_config0, xuartps_config0->BaseAddress);
      if (status != XST_SUCCESS) {
        return XST_FAILURE;
      }

     xuartps0_format.BaudRate=9600u;
     xuartps0_format.DataBits=XUARTPS_FORMAT_8_BITS;
     xuartps0_format.Parity=XUARTPS_FORMAT_NO_PARITY;
     xuartps0_format.StopBits=XUARTPS_FORMAT_1_STOP_BIT;
     XUartPs_SetDataFormat(&xuartps0, &xuartps0_format);
     XUartPs_SetFifoThreshold(&xuartps0,63u);/* Receive threshold*/
     XUartPs_SetOperMode(&xuartps0,XUARTPS_OPER_MODE_NORMAL);
     XUartPs_SetRecvTimeout(&xuartps0,4u);
     XUartPs_EnableUart(&xuartps0);



      xuartps_config1 = XUartPs_LookupConfig(XPAR_XUARTPS_1_DEVICE_ID);
          if (xuartps_config1 == NULL) {
            return XST_FAILURE;
          }
        XUartPs_ResetHw(xuartps_config1->BaseAddress);
          status1 = XUartPs_CfgInitialize(&xuartps1, xuartps_config1, xuartps_config1->BaseAddress);
          if (status1 != XST_SUCCESS) {
            return XST_FAILURE;
          }

        xuartps1_format.BaudRate=9600u;
        xuartps1_format.DataBits=XUARTPS_FORMAT_8_BITS;
        xuartps1_format.Parity=XUARTPS_FORMAT_NO_PARITY;
        xuartps1_format.StopBits=XUARTPS_FORMAT_1_STOP_BIT;
        XUartPs_SetDataFormat(&xuartps1, &xuartps1_format);
        XUartPs_SetFifoThreshold(&xuartps1,63u);/* Receive threshold*/
        XUartPs_SetOperMode(&xuartps1,XUARTPS_OPER_MODE_NORMAL);
        XUartPs_SetRecvTimeout(&xuartps1,4u);
        XUartPs_EnableUart(&xuartps1);



        for(;;)
                {

                    if (XUartPs_IsReceiveData(((&xuartps0)->Config.BaseAddress)))
                    {
                        XUartPs_SendByte(((&xuartps1)->Config.BaseAddress),XUartPs_RecvByte(((&xuartps0)->Config.BaseAddress)));
                        //XUartPs_ReadReg(xuartps0,XUARTPS_FIFO_OFFSET);
                        //XUartPs_Send(&xuartps1, XUartPs_RecvByte(((&xuartps0)->Config.BaseAddress)), 32);
                }           if (XUartPs_IsReceiveData(((&xuartps1)->Config.BaseAddress)))
                            {
                                //XUartPs_ReadReg(xuartps1,XUARTPS_FIFO_OFFSET);
                                //XUartPs_Send(&xuartps1, XUartPs_RecvByte(((&xuartps0)->Config.BaseAddress)), 32);
                                XUartPs_SendByte(((&xuartps0)->Config.BaseAddress),XUartPs_RecvByte(((&xuartps1)->Config.BaseAddress)));

                        }

                }






cleanup_platform();
return 0;
}

I set up the Terminal with a 9600 baud rate, 8 Data Bits, 1 Stop bit, No Parity or Flow Control. Also, SEM has a 9600 baudarate and same goes (as you can see on the code) for UART0 and UART1.

After I program the FPGA and run the code I get something like this:

enter image description here

While I was expecting something like this:

X7_SEM_V4_1 
SC 01 
FS {2-digit hex value} 
ICAP OK 
RDBK OK 
INIT OK 
SC 02 

As you can see the latter part looks fine, but the first part doesn't. Different baud-rate combinations of the four components (SEM, UART0, UART1, Terminal) show slight different results (not better though) but still not correct. An older version of my code, that time with SEM & Terminal on 9600 and the UARTs on 115200 (which doesn't really makes sense) gave me an output that was correct at the beggining but false at the end:

Z7_SeM_V6_9MSS"29MfS"2RMISIR"OKMRfRK"OKMINIV"OKMSS"22MO>"

Some imporant notes are:

  • SEM uses a 100MHz clock
  • UART 1 is configured through the Zynq Processing System Settings in Vivado with LVCMOS 2.5V just like the SEM IP.
  • I'm using Vivado 2014.4
  • The system is implemented in polled mode
  • The Terminal responds to commands (for example "S" command for a status report) but the output is still wrong.

Any ideas on this isssue? Thank you.

\$\endgroup\$
  • \$\begingroup\$ Do you have access to a logic analyzer or oscilloscope? \$\endgroup\$ – uint128_t May 8 '17 at 0:30
  • \$\begingroup\$ 1) Check for Noise on ground, supply then signals 2) Check bit period and try 0011 patterns like 55AA then confirm signal integrity 3) compare/verify UART settings and include odd parity in future. Start with lowest speed and increase if OK. and keep your long wired signals twist-paired with ground and your grounds solid (low inductance) \$\endgroup\$ – Sunnyskyguy EE75 May 8 '17 at 4:19
  • \$\begingroup\$ All the errors include hidden ASCII like CR LF and the next character. It seems like RAM /software errors not Serial port errors. \$\endgroup\$ – Sunnyskyguy EE75 May 8 '17 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.