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

Video Series 33 - Visualizing the Video_Mixer example design using the ZC702 board’s On-Board HDMI (Part 2 - Software Application)

4 0 1,936

Now that we have the hardware built from Part 1 (Video Series 32), we need the drivers to match.


Here I will step through adding the necessary code to connect the default example design to the added hardware, which will allow the Video Mixer to show on a monitor. Having a monitor is incredibly useful for creating and debugging video projects.

  1. Finish Part 1 of this tutorial (Video Series 32) making sure the HDF file has been exported from Vivado.
  2. Launch SDK from the previously created Vivado project. Select File -> Launch SDKVideo Series 33 1.png



  3. Create a new Board Support Package (BSP). Select File -> New -> Board Support Package -> Finish -> OKVideo Series 33 2.pngVideo Series 33 3.png
  4. Generate the v_mix_0 example design to use as a starting platform for our Application.

    The system.mss tab opens automatically. Find the line corresponding to the Video Mixer (v_mix_0) and select Import Examples -> select check box -> okVideo Series 33 4.pngVideo Series 33 5.png

  5. You should now have an application project available in the Project Explorer. There will be errors because this application was not written for the ZC702 board, but we will address these in the next step.Video Series 33 6.png
  6. To remove the errors in the application, update the call for the PS of the ZCU102 (XPAR_PSU_ACPU_GIC_DEVICE_ID) and replace it with the PS7 for the ZC702 (XPAR_PS7_SCUGIC_0_DEVICE_ID) as shown in the image below. 

    Video Series 33 7.png
  7. Create a new application to build our application project. The easiest way to do this is to create a new hello world project as described in XVES20 and shown below.
    Note: because the v_mix application was not targeted to the ZC702 board by default, creating a new application will solve the problem by adding updated platform.h, platform.c and platfomr_config.h files targeting the ZC702 board.


    2019-10-09 17_49_15-xcoapps64_20 (xcoapps64_20 (samk)) - VNC Viewer.png2019-10-09 17_49_27-xcoapps64_20 (xcoapps64_20 (samk)) - VNC Viewer.png


  8. Once you have a new project, copy the full contents of xv_mix_example.c file found in standalone_bps_0_xv_mix_example_1/src/ into helloworld.c and overwrite all of the previous contents of helloworld.c.
  9. Copy logo.c from standalone_bsp_0_xv_mix_Example_1/src/ to your new project/src/. This can be done by clicking and dragging the file. 
  10. Add in the source files included in the ./sw/src/ folder in the attached ZIP. Click and drag can be used, or you can rightclick on src and select an import option.
  11. Now we will start adding the code from XVES19/20/21 required to include the HDMI output.
  12. In helloworld.c add include calls for iic_utils and xclk_wiz.  Then instantiate it, and also instantiate the tpg as shown below.
    Its header file is already included in the project.

    // Add includes near existing #includes around line 60
    #include "iic_utils.h" #include "xclk_wiz.h"
    // Add instiantiations near other instantiations around line 104 XIicPs IicPs_inst; XV_tpg tpg_inst; XClk_Wiz clk_wiz;
  13. Update the video test modes to SVGA and 720:

    //This code is around line 880
    XVidC_VideoMode TestModes[NUM_TEST_MODES] = { XVIDC_VM_SVGA_60_P, XVIDC_VM_720_60_P };
  14. Add in the function to configure the clock from XVES21:

    //Add funciton declaration below existing declarations around line 170
    static void ConfigClock(XVidC_VideoMode VM);
    //Add function definition /*****************************************************************************/ static void ConfigClock(XVidC_VideoMode VM) { // Clocking Wizard Configuration //Configure the CLKOUT0 DIV if( VM == XVIDC_VM_SVGA_60_P){ Xil_Out32(clk_wiz.Config.BaseAddr + 0x208, 0xFA10); //800x600 } else { Xil_Out32(clk_wiz.Config.BaseAddr + 0x208, 0x000A); //720p } Xil_Out32(ClkWiz_CfgPtr->BaseAddr + 0x25C, 0x3); xil_printf("INFO: clock configured \n\r"); }
  15. In Main, add the lines below to configure the PS IIC controller and to initialize the clock as described in XVES20/21:

    // These an go in the beginning of main after Xil_ExceptionEnable(); around line 921.
    //Configure the PS IIC Controller ps_iic_init(XPAR_XIICPS_0_DEVICE_ID, &IicPs_inst); // Set the iic mux to the ADV7511 set_iic_mux(&IicPs_inst, 0x2, 0x74); XClk_Wiz_CfgInitialize(&clk_wiz, &clk_wiz.Config,XPAR_CLK_WIZ_0_BASEADDR);
  16. Below the previously added code, add the IIC configure loop as shown in XVES 20/21:

      // Set the iic mux to the ADV7511
         set_iic_mux(&IicPs_inst, 0x2, 0x74);
         //Check the state of the HPD signal
         u8 monitor_connected = 0;
         u8 temp = 2;
     		monitor_connected = check_hdmi_hpd_status(&IicPs_inst, 0x39);
     			xil_printf("HDMI Monitor connected\r\n");
     			// ADV7511 Basic Configuration
     			// ADV7511 Input / Output Mode
     			//YCbCr 422 with Separated Syncs
     			iic_write2(&IicPs_inst, 0x39, 0x15, 0x1);
     			//YCbCr444 Output Format, Style 1, 8bpc
     			iic_write2(&IicPs_inst, 0x39, 0x16, 0x38);
     			//Video Input Justification: Right justified
     			iic_write2(&IicPs_inst, 0x39, 0x48, 0x08);
     			xil_printf("HDMI Setup Complete!\r\n");
     		} else {
     			xil_printf("No HDMI Monitor connected / Monitor Disconnected\r\n");
     	monitor_connected = check_hdmi_hpd_status(&IicPs_inst, 0x39);
  17. Add the clock configuration into the video mixer application where the VTC is configured:

      // put ConfigClock below ConfigVTC around line 1016
    //Add Line below to Configure Clock ConfigClock(VidStream.VmId);
  18. There was an issue found with the Clock Wizzard in 7 series which requires a Hardware Rest. Because this design does not implement a GPIO to reset the Clock Wizzard between resolutions set the example design to only 1 loop (resolution).
    // Around Line 90 update NUM_TEST_MODES to 1 from 2
    // If a GPIO reset is added this can be updated to more loops
    #define NUM_TEST_MODES    (1)
  19. All code changes are now done. Build the application.
  20. Run and test on Hardware. Printing is enabled, so connect a UART when testing to see the output.2019-10-23 10_36_45-COM11 - Tera Term VT.png

    2019-10-09 18_55_03-Photo - Google Photos.png

Liked this Video Series entry?

  • You can give Kudos using the Kudos button  kudos.JPG
  • Share it on social media using the Share button share.JPG

  • Feel free to comment on this topic or to create a new topic on the forums to ask questions

Want more from the Video Series?