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

 

Parents
  • 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
  • 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

  • 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
  • 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?

  • 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
  • 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?
  • 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
  • I ran it for a while and when I hit suspend here's the call stack:

     

    Any other setting I should be configuring?

  • 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
  • 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);
    }
    }

  • Hi zfeng,

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

    Regards,
    adboc

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

     

  • 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
  • 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.
Reply
  • 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.
Children
  • 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
  • The example works ok with/without the UART framework as I mentioned. It's just my actual project when I add the UART it doesn't display anything on the board when loading the software to it =/

    I tried changing the priority to 5 on the UART and no luck so far.

     

  • Hi zfeng,

    Sorry for my misunderstanding. Please try comparing your project with the example TouchGFX project in terms of pin configuration, memory assignment, thread/interrupt priorities, additional routines like R_BSP_WarmStart (User_BSP_WarmStart.c in the original example).

    Regards,
    adboc
  • Hi adboc,

    I've been comparing the configurations used for my project and the blinky Thread X example w/ uart

    • For ports: the sample has the followed enabled but my project doesn't: P100-P103
      • And my project has the following ports enabled but not the sample: P115, P511-512, P609-611
    • For peripherals: IIC2 is enabled on my project but not the sample
      • SPI0 is enabled on the sample but not my project
    • The two projects only share the HAL/Common and uart Threads stacks. Both have the same interrupt priorities configured.
    • Only my project has User_BSP_Warmstart.c. This file is not present on the sample project for me. The source code is below for this file.

    /*
    * User_BSP_WarmStart.c
    *
    * Created on: 13 Jan 2016
    * Author: bakerj
    */

    #include "bsp_api.h"

    #if defined(__ICCARM__)
    /* Need to installed the source code for the IAR Runtime library */
    /* Need to add $TOOLKIT_DIR$\src\lib to include path */
    #include "xcstartup.h"
    #pragma section = "SHT$$PREINIT_ARRAY" const
    #pragma section = "SHT$$INIT_ARRAY" const
    #endif

    extern void __libc_init_array (void);
    void R_BSP_WarmStart (bsp_warm_start_event_t event);


    void R_BSP_WarmStart (bsp_warm_start_event_t event)
    {
    if (BSP_WARM_START_PRE_C == event)
    {
    /* C runtime environment has not been setup so you cannot use globals. System clocks and pins are not setup. */
    }
    else if (BSP_WARM_START_POST_C == event)
    {
    /* C runtime environment, system clocks, and pins are all setup. */
    /* Static Constructor for C++ */
    #if defined(__GNUC__)
    __libc_init_array();
    #elif defined(__ICCARM__)
    void const * pibase = __section_begin("SHT$$PREINIT_ARRAY");
    void const * ilimit = __section_end("SHT$$INIT_ARRAY");
    __call_ctors((__func_ptr *)pibase, (__func_ptr *)ilimit);
    /* End - Static Constructor */
    #endif
    }
    else
    {
    /* Unhandled case. */
    }
    }

      

    Note also that sometimes when I am using synergy configuration  on my project I get this exception. 

     

     

    Please let me know if this helps with finding what might be missing on my project. Thanks.

  • Hi zfeng,

    "For ports: the sample has the followed enabled but my project doesn't: P100-P103
    ...
    SPI0 is enabled on the sample but not my project"

    This is possible reason why the screen is blank. The SPI driver on channel 0 is required to initialize the display on SK-S7G2 and PK-S5D9 boards.

    I'm not sure, if we're looking at the same example project, because in my project there is User_BSP_WarmStart.c. I also have SPI driver on SCI, so SCI0 is configured, not SPI0.

    Regards,
    adboc

  • My project is configured for SCI0 although its operation mode is set as Asynch UART.

     

     

    The sample project I used was this one: https://renesasrulz.com/synergy/b/weblog/posts/hello-world-using-the-uart-application-framework

    It uses the Blinky Thread X template.

    Which project example are you using that utilizes the LCD and UART? Are you using the demo under TouchGFX_Renesas_Synergy_BSP\app\demo\Renesas_SK_demo? And then adding the UART stack?

  • Update: I loaded the SK_demo_2014 and added the same uart stack configuration as the tutorial and the same thing happens (nothing loads on the screen). So I decided to change the RX/TX to pins 100/101 as you had it. There appears to be a conflict when using 410/411.

     

    I compiled and loaded the software and this time it boots! BUT, the uart application is not working. I tried to get a reply back on the terminal (tera term) after typing 'open' and it doesn't trigger anything.

    When I was just testing the uart alone in a project it was working fine when using 410/411 pins on the breakout headers:

     

    For P101/100 I'm using the pins 3 and 5 on PMODA:

    Here's my uart application:

    uart_thread_entry.cpp

    extern "C" {
    #include "uart_thread.h"
    }
    void uart_thread_entry(void);

    uint8_t Message[]="Damper is opening \n\r";
    static uint8_t uart_buffer[8];
    static uint8_t read_byte;
    static uint8_t indx;
    static bool status;

    /* uart entry function */
    void uart_thread_entry(void)
    {
    g_sf_comms0.p_api->open(g_sf_comms0.p_ctrl, g_sf_comms0.p_cfg);
    while (1)
    {
    status = g_sf_comms0.p_api->read(g_sf_comms0.p_ctrl, &read_byte,1,TX_WAIT_FOREVER);
    if(indx>sizeof(uart_buffer))
    indx=0;
    else {
    indx++;
    }
    uart_buffer[indx]=read_byte;
    for(int in=0; in <sizeof(uart_buffer); in++)
    {
    if(uart_buffer[in]=='o')
    {
    if(uart_buffer[in+1]=='p')
    {
    if(uart_buffer[in+2]=='e')
    {
    if(uart_buffer[in+3]=='n')
    {
    //g_sf_comms0.p_api->write(g_sf_comms0.p_ctrl, "Renesas Synergy !!!! \r\n ",24,100);
    g_sf_comms0.p_api->write(g_sf_comms0.p_ctrl, Message,sizeof(Message),0);
    indx=0;
    for(int i=0;i<sizeof(uart_buffer);i++)
    {
    uart_buffer[i]=0;
    }
    }
    }
    }
    }
    }
    if(status)
    while(1);
    }
    }

     

     

    Now to figure out why TX/RX on PMODA aren't functioning.

  • Hi zfeng,

    Pins P100-102 are also connected to a display, they're needed for the SPI driver which performs initialization. Once the screen is initialized, these pins might be used for PMODA, because the SSL (CS) pin is not shared. PMODB's SPI pins are not shared, so it's easier to get them working.

    Moreover, if you're using the Communications Framework on UART, you don't have to call g_sf_comms0.p_api->open - it's called earlier in the generated part of code. Could you check the returned value from g_sf_comms0.p_api->read? Have you configured UART settings in the configurator properly?

    Regards,
    adboc
  • " PMODB's SPI pins are not shared, so it's easier to get them working."

    What's the difference between pins 411/410 on the J22 header vs. 411/410 on the PMOD J14 header? 

     

    When using the UART example tutorial, it only works when using 411/410 on J22. But if you remember, using 411/410 on SCI0 on the sample project with LCD stacks doesn't boot up the software on the board. So right now I'm at a crossroads.

     

    This is how the uart project works on its own. I type 'open' and it acknowledges and it echoes back the results:

     

    So far I've tried PMODA and PMODB with no luck even on the stand-alone uart example.

  • Hi zfeng,

    For display initialization the SPI driver on RSPI can be used. In you would like to use UART on pins P410, P411 I suggest doing the following:

    1. Exchange "g_spi_lcdc" SPI Driver on r_sci_spi for SPI Driver on r_rspi - please use the same name, bitrate, callback name

    You should remove this driver:

    And add this one:

    2. Change pin configuration for SCI0 and SPI0:

    3. Now SCI on channel 0 will use pins P410 and P411, so configure the UART driver to use channel 0:

     

    Regards,
    adboc

  • Thanks for the info. I did the modifications and the UART application works but the GUI is still not loading.

     

    r_spi driver

     

    SCI0 config

    SPI0 config

     

    UART application response

     

    Thread stacks

     

    If possible to move along quicker, can you use my project file? I've uploaded here:

    https://www.dropbox.com/s/8n02ka2r0bdgvbn/Renesas_SK_demo.7z?dl=0

     

    Thanks.

  • Hi zfeng,

    I encountered the same issue as you did. It seems the supplied display driver (inc/lcd.h and lcd_setup.c) is not working properly with the SPI driver on RSPI. Please find the attached updated driver and remove inc/lcd.h and lcd_setup.c files and all references.

    Put display_init folder and its contents in src/ directory of your project.

    In g_spi_lcdc (on RSPI) set callback to NULL, Data sampling on even edge, high when idle.

    Remember to set these pins as output: P115, P610, P611.

    In Main_thread_entry.c, include "display_init/display_init.h" and instead of

    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);
    }

    just call:

    display_init(&g_spi_lcdc);

    display_init.zip

    Regards,
    adboc

  • There appears to be activity on the GUI thread stack when pausing the debug session. The UART app is still functioning. However, still nothing on the LCD board.

    For lcd.h and lcd_setup.c I excluded the files from the build as  you can see from the screenshots below.

     

    r_spi properties:

    P115/P610/P611:

     

    main thread entry.c includes and void function:

     

     

    GUI thread stack

     

  • Hi zfeng,

    Sorry, I forgot to mention that RSPI driver should have bitrate set to 500000. Please find your project with required modifications, however note that it uses TouchGFX 4.9.0. Please rename these files to Renesas_SK_demo2p.zip.001 and Renesas_SK_demo2p.zip.002, these are two parts of one zip archive.

     Renesas_SK_demo2p.zip.001.zip

    Renesas_SK_demo2p.zip.002.zip

    Regards,
    adboc

  • I set the bitrate to 500000 and it still doesn't load the GUI. I can't unzip the files. They appear to be corrupt.