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

 

  • In reply to 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.

     

  • In reply to zfeng:

    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
  • In reply to 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.

  • In reply to zfeng:

    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

  • In reply to 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?

  • In reply to zfeng:

    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.

  • In reply to zfeng:

    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
  • In reply to 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.

  • In reply to zfeng:

    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

  • In reply to 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.

  • In reply to zfeng:

    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

  • In reply to 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

     

  • In reply to zfeng:

    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

  • In reply to 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.
  • In reply to zfeng:

    Hi zfeng,

    I cannot upload a whole workspace here, but here's the project which contains proper configuration (configuration.xml, S7G2-SK.pincfg), display_init driver and updated Main_thread_entry.c file.

    SK_demo_2014_TouchGFX.zip

    Regards,
    adboc