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:

    I copied the four files [configuration.xml, S7G2-SK.pincfg, display_init driver and updated Main_thread_entry.c] to my project.

    The GUI LCD is loading now but the UART application doesn't function =/

    I'm using the demo project from touchgfx 4.8.0 to run this. I was trying to find the same demo project for tgfx 4.9.3 but it no longer comes in the installation. Is your testing being done on 4.9.3?

    You can upload files into my dropbox since it's hard to share here:
    www.dropbox.com/.../WGzmWbV9R4ortcqdePxO
  • In reply to zfeng:

    Hi zfeng,

    I've uploaded the whole workspace. Yes, I've been using 4.9.3, some changes are needed to make it work on this version.

    Regards,
    adboc
  • In reply to adboc:

    adboc,

    Thanks for the workspace. The GUI is running ok like mine was, but the UART app is still not responding. Are both threads working for you? Here is the stack.

  • In reply to zfeng:

    Hi zfeng,

    Sorry, I forgot to enable autostart of the UART thread.

    Please set thread's settings:

    And UART driver's settings:

    Regards,
    adboc

  • In reply to adboc:

    Thanks adboc. I had to put the project on hold for a bit but I finally got it working with my touchgfx project. I had to replace my project's Target folder with the one used in the project you sent me. I ran into several errors mostly related to linked libraries missing or wrong paths to library files. After fixing all that my touchgfx projects runs both the GUI and UART thread well now.

    My next step is to try sending a UART message using my touchscreen's toggle button and print a message on the serial monitor.

    Can I use the uart thread commands within the touchgfx files? I'm assuming I'll need to add the header file "uart_thread.h" into my touchgfx source files.

    This my homeview.cpp file: https://pastebin.com/ZrhYtMup

    homepresenter.cpp file: https://pastebin.com/ghEPcUEE

     

    Under this function in homeview.cpp:

    void homeView::lightToggled()
    {
    bool new_state = lightSwitch.getState();

    touchgfx_printf("lightToggled: %d\n", new_state);

    //inform Model through presenter
    presenter->lightToggled(new_state);
    }

    I'm thinking to use the command to write:

    g_sf_comms0.p_api->write(g_sf_comms0.p_ctrl, Message,sizeof(Message),0);

    Where Message would be something like:

    uint8_t Message[]="light state has changed \n\r";

     

    I'm going to see if this works. Might there be something missing that might not make it work? Thanks!

  • In reply to adboc:

    Hi Adboc,

    Can you share your SK project with Touchgfx and UART? I am doing the same work, but I need to make it on the DK board.

    The link:

    www.dropbox.com/.../93aZtJp2bj6YGyxdDlTf

    BR,
    James Jian
  • In reply to JHJ:

    I uploaded the project into your dropbox JHJ
  • In reply to zfeng:

    Hi zfeng,


    Yes, you can use UART thread commands from other thread, but as you've already notices, "uart_thread.h" should be included to make g_sf_comms0 visible. The write function can be used in this way, however I suggest using a larger value for wait option (the last parameter) - in other case it may return with a non-zero error code, because the message cannot be written within specified timeout.

    Regards,
    adboc
  • In reply to adboc:

    It appears to be working. I was getting odd characters when I had the last parameter set to 0:

    After reading your suggestion it prints out the message correctly. 

    Is the timeout parameter in milliseconds? I set it to 5 but not sure if it's the most optimized value to use for sending a serial message. Thanks for all the help. My next step is to have my other device read this message to trigger an event.

  • In reply to zfeng:

    Hi zfeng,

    thanks. I will check it out.
  • In reply to zfeng:

    Hi zfeng,

    The value is in ThreadX ticks, by default one tick lasts 10 ms.

    Regards,
    adboc