SKS7G2 - Using UART stack on a touchgfx application

Hey all,

Looking to see if I can get this working. I've built an application with TouchGFX (https://touchgfx.com/renesas/sk-s7g2/). I want to implement UART to the application to communicate with another board when using the touchscreen. To get myself familiar with UART using e2 studio, I completed this tutorial first: https://renesasrulz.com/synergy/b/weblog/posts/hello-world-using-the-uart-application-framework

The 'Hello World' project works and now I'm trying to implement the UART stack on my touchgfx project. I was able to add the UART stacks on the touchgfx project in e2 studio. The project compiles with no errors (at first I was getting errors but I had to change the channel of "g_uart0 UART Driver on r_sci_uart" to channel 8. I think since on the Main Thread Stack there is a lcd stack that was on channel 0 it was causing a conflict).

The project compiles but once I load it into the board I'm just getting a blank screen. I've been running into "Unhandled event loop exceptions" when I try to compile sometimes. But there never actually is any error during compilation. I've attached the log file and some images of the workspace.

log011618.log

 

  • Hi zfeng,

    While the screen is blank please suspend the application and see what the application is actually doing (a call stack). Did it pass the initialization of the screen?

    Regards,
    adboc
  • In reply to adboc:

    Ok I stepped through the application and this is a suspect of the issue:

    Can't find a source file at "C:\ExpressLogic/ssp\src\framework\el\tx\tx_src\tx_initialize_kernel_enter.c"
    Locate the file or edit the source lookup path to include its location.

    Here is a sequence of images on what happens.

    At the main it executes "tx_kernel_enter()"

     

    But then it cannot find the source "tx_initialize_kernel_enter.c"

     

    As we move to calling the three threads:

    Main_thread_create ();
    GUIthread_create ();
    uart_thread_create ();

     

    When it's calling "tx_thread_create "it again cannot find the source. This happens for each of the three threads above

     

     

     

    It's weird because when I load the application in separate projects (one for touchgfx and the other UART tutorial) there's no issue of this missing source. Thanks for looking into this.

    Software I'm using:

    e2 studio
    Version: 5.4.0.018

    SSP 1.2.0

  • In reply to zfeng:

    zfeng,

    To debug through the ThreadX source, you must include the ThreadX source as a module in the Synergy configurator. Otherwise, the object library is used and there is no source code to view in the debugger.

    -gary
  • In reply to garyj:

    Thanks for pointing that out. I enabled tx_src in the components section of Synergy configurator and now I am getting the following:

     

     

    Decryption not permitted file "......."

    Is there anything else that I need to add?

  • In reply to zfeng:

    Hi zfeng,

    To see the source code of X-Ware components, you should have a production/development license. You may apply for the license in the Synergy Gallery.

    Regards,
    adboc
  • In reply to adboc:

    I won't be able to retrieve a dev license at the moment. Is there a way I can still find/debug what the issue is with the application?
  • In reply to zfeng:

    Hi zfeng,

    Please start the application and let it run for a while, then suspend the application and take a screenshot of the call stack.

    Regards,
    adboc
  • In reply to adboc:

    I ran it for a while and when I hit suspend here's the call stack:

     

    Any other setting I should be configuring?

  • In reply to zfeng:

    Hi zfeng,

    This shows only the call stack of the "Main Thread" only, could you show what other threads are actually doing? Do you call tx_thread_suspend in the "Main Thread"? Which thread the application is trying to suspend?

    Regards,
    adboc
  • In reply to adboc:

    I don't think the other threads are doing anything. When I pause/suspend the debug session and select a Thread, it should show the call stack for that selected thread correct?

    When the session is running:

    Paused/suspend session and GUI Thread selected:

     

    uart thread selected:

     

     

    In the Main_thread_entry.c file there are a couple of tx_thread_suspend functions being called. However, one is commented out.

     

    void Main_thread_entry(void)
    {
    ssp_err_t err;

    if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)
    { /* Debugger is connected */
    initialise_monitor_handles();
    }

    err = g_spi_lcdc.p_api->open(g_spi_lcdc.p_ctrl, g_spi_lcdc.p_cfg);
    if (SSP_SUCCESS != err)
    {
    while(1);
    }

    /* Setup the controller used on the LCD panel */
    ILI9341V_Init();

    err = g_spi_lcdc.p_api->close(g_spi_lcdc.p_ctrl);
    if (SSP_SUCCESS != err)
    {
    while(1);
    }

    err = touch_set_up();
    if (SSP_SUCCESS != err)
    {
    while(1);
    }

    err = g_display.p_api->open(g_display.p_ctrl ,g_display.p_cfg);
    if (SSP_SUCCESS != err)
    {
    while(1);
    }

    err = g_display.p_api->start(g_display.p_ctrl);
    if (SSP_SUCCESS != err)
    {
    while(1);
    }
    //#define TEST

    #ifndef TEST
    tgfx_main();

    //tx_thread_suspend(&Main_thread);
    #else
    uint16_t *p_display,src_image_1,src_image_2;
    uint16_t x;
    uint16_t y;
    uint32_t i = 0;


    /* Fill the 2 frame buffers with known data */
    p_display = (uint16_t *)g_display_fb_background[0];
    src_image_1 = (uint16_t *)0x0008c2d4;
    src_image_2 = (uint16_t *)0x000ac0d4;

    for(x = 0; x < g_display.p_cfg->input->hstride; x++)
    {
    for (y = 0; y < g_display.p_cfg->input->vsize; y++)
    {
    *p_display++ = COL_BLUE;
    }
    }
    p_display = (uint16_t *)g_display_fb_background[0];
    for(x=0;x<20;x++)
    *p_display++ = COL_WHITE;
    // for(x = 0; x < 240; x++)
    // {
    // for (y = 0; y < 272; y++)
    // {
    // *p_display++ = src_image_1++;
    // }
    // }

    p_display = (uint16_t *)g_display_fb_background[1];

    for(x = 0; x < g_display.p_cfg->input->hstride; x++)
    {
    for (y = 0; y < g_display.p_cfg->input->vsize; y++)
    {
    *p_display++ = COL_RED;
    }
    }
    // for(x = 0; x < 240; x++)
    // {
    // for (y = 0; y < 272; y++)
    // {
    // *p_display++ = src_image_2++;
    // }
    // }

    #endif
    tx_thread_suspend(tx_thread_identify());
    while (1)
    {
    #ifdef TEST
    /* Now switch the frame buffer */
    g_display_runtime_cfg_bg.input.p_base = (uint32_t *)g_display_fb_background[i];

    do
    {
    err = g_display.p_api->layerChange(g_display.p_ctrl, &g_display_runtime_cfg_bg, DISPLAY_FRAME_LAYER_1);
    }
    while (SSP_ERR_INVALID_UPDATE_TIMING == err);
    i += 1UL;
    if (2 == i)
    {
    i = 0;
    }
    #endif
    tx_thread_sleep (50);
    }
    }

  • In reply to zfeng:

    Hi zfeng,

    You should expand each thread's call stack using the arrow on the left:

    Regards,
    adboc

  • In reply to adboc:

    Ah, I thought the call stack would also be visible on window at the bottom. Thanks.

     

  • In reply to zfeng:

    Hi zfeng,

    Thanks. Seems like the GUI thread tries to communicate to the touch panel controller. Are you sure the touch panel framework is configured properly? Could you check if P511, P512 pins are configured for IIC2 and P609 is configured as an output?

    Just to clarify, without the UART thread the application runs as expected?

    Regards,
    adboc
  • In reply to adboc:

    It appears to be configured correctly since I didn't change the settings that was on the original GUI project.

     

     

    And yes the application runs fine before adding the UART thread. And I have a separate UART project I created to make sure UART works on the board.

    Here's the call stack from just the touchgfx application project:

     

    And here's the call stack from the UART example project I did which runs fine:

     

    Some things I've noticed:

    • When I add the UART thread stack to the project, the g_uart0 channel is defaulted to 0. It doesn't compile and outputs this error:

      13:05:30 **** Incremental Build of configuration Debug for project application ****
      make -j4 all
      'Building file: ../src/synergy_gen/uart_thread.c'
      'Invoking: Cross ARM C Compiler'
      C:\Renesas\e2_studio\eclipse\../.....
      ' '
      'Building target: application.elf'
      'Invoking: Cross ARM C++ Linker'
      arm-none-eabi-g++ @"application.elf.in"
      ./src/synergy_gen/uart_thread.o:(.vector_info.SCI_0_ERI+0x0): multiple definition of `g_vector_info_SCI_0_ERI'
      ./src/synergy_gen/Main_thread.o:(.vector_info.SCI_0_ERI+0x0): first defined here
      ./src/synergy_gen/uart_thread.o:(.vector.SCI_0_ERI+0x0): multiple definition of `g_vector_SCI_0_ERI'
      ./src/synergy_gen/Main_thread.o:(.vector.SCI_0_ERI+0x0): first defined here
      ./src/synergy_gen/uart_thread.o:(.vector_info.SCI_0_TEI+0x0): multiple definition of `g_vector_info_SCI_0_TEI'
      ./src/synergy_gen/Main_thread.o:(.vector_info.SCI_0_TEI+0x0): first defined here
      ./src/synergy_gen/uart_thread.o:(.vector.SCI_0_TEI+0x0): multiple definition of `g_vector_SCI_0_TEI'
      ./src/synergy_gen/Main_thread.o:(.vector.SCI_0_TEI+0x0): first defined here
      ./src/synergy_gen/uart_thread.o:(.vector_info.SCI_0_TXI+0x0): multiple definition of `g_vector_info_SCI_0_TXI'
      ./src/synergy_gen/Main_thread.o:(.vector_info.SCI_0_TXI+0x0): first defined here
      ./src/synergy_gen/uart_thread.o:(.vector.SCI_0_TXI+0x0): multiple definition of `g_vector_SCI_0_TXI'
      ./src/synergy_gen/Main_thread.o:(.vector.SCI_0_TXI+0x0): first defined here
      ./src/synergy_gen/uart_thread.o:(.vector_info.SCI_0_RXI+0x0): multiple definition of `g_vector_info_SCI_0_RXI'
      ./src/synergy_gen/Main_thread.o:(.vector_info.SCI_0_RXI+0x0): first defined here
      ./src/synergy_gen/uart_thread.o:(.vector.SCI_0_RXI+0x0): multiple definition of `g_vector_SCI_0_RXI'
      ./src/synergy_gen/Main_thread.o:(.vector.SCI_0_RXI+0x0): first defined here
      collect2.exe: error: ld returned 1 exit status
      make: *** [application.elf] Error 1
      makefile:107: recipe for target 'application.elf' failed

      13:05:36 Build Failed. 2 errors, 0 warnings. (took 5s.909ms)

     

    However, once I change to a different channel (8) it compiles fine. I don't know if this channel issue is related to the application not booting up.

    • if I delete the UART thread stack on the synergy configuration and the associated files, the application still doesn't boot up. I have to delete the Renesas folder with the board's files and replace with a backup of the original files.
  • In reply to zfeng:

    Hi zfeng,

    You get these errors, beacuse each instance tries to bind ISRs to SCI interrupts. You may use the same channel, but it's necessary to define a macro called SSP_SUPPRESS_ISR_<instance_name> (e.g. SSP_SUPPRESS_ISR_g_uart0) for your instance.

    However I don't think this is related to the issue you see. I've succesfully run the example with and without the Communications Framework on UART (tested on SCI8), the new thread has priority set to 5 - please try using it since the main and the GUI threads are both set to 1.

    Regards,
    adboc