Running Threaded Blinky on the Synergy Platform

Overview

This self paced learning exercise show you how to create a Blinky design (Blink an LED on your Synergy board) using a simple thread implementation. This exercise uses brief descriptions of several common actions within the tool flow. This assumes you are somewhat familiar with the various operations within e2 studio. Feel free to 'pop out' of this guide and refresh your understanding of e2 studio operations by referring to the non-threaded example designs that illustrate each step in full step-by-step detail.

Goal

After completing this how-to you will have created a simple threaded design from scratch and can move on to more complex implementations.

Use each step section to describe the instructions needed to achieve the goal.

Initial Set-Up

You must first have the Synergy software tool flow installed and a target Synergy board available to see Blinky work in hardware. If you don't, follow the below link to the Getting Started How in the Synergy Knowledge Base.

If you followed the previous step you should have the Synergy Platform tool flow working and you should have exercised your target board, most likely with the non-threaded version of Blinky. Now you are ready for a threaded version.

Open e2 studio and create a new Synergy Project (refer back to the above How To if you need a reminder).

Target your board and select the BSP with Thread-X option.

You should now have familiar a starting point for adding Blinky code.

Add Threaded Blinky Code

In this step you will add the code for implementing the Threaded version of Blinky.

Open the Threads Tab in the Configuration Window.

Click on New to bring up a New Thread.

Press the Generate Project Content button.

You should now have a file called new_thread_entry.c

Open new_thread_entry.c and replace all the code below the first line comment with the following code:

Save the changes to the file and build the debug configuration of your project. It may take a minute or two (or perhaps more) so be patient. Also- it may stay 'stuck' on Build Project (55%) for a while and then finish up all at once. Don;t worry if something like that happens on your design.

The design should build without errors. If not, look carefully at your added code.You may have missed or added some characters. When your code builds without errors, you are ready to run threaded blinky on your target board.

Run Threaded Blinky on Your Board

Connect your board as you did when running your previous example design.

Initialize the Debugger and select your new project build configuration.

Click the Debug button to bring up the debug perspective.

The debug session will halt at the beginning of the design, so you need to press the Resume button twice to get it to begin execution on your board.

Your LED should now be blinking on and off. It should stay on for 1 second and then go off for 1 second until you pause or stop the debug session.

You have completed your first threaded design with Synergy!

How Threaded Blinky Works

Threaded Blinky begins operation in the thread instead of in hal_entry as you may have noticed in previous examples (such as Hal Blinky). The Blinky thread is the only one in this design, so thats were the design starts. If multipe threads existed, each would have their own starting point.

The first part of threaded Blinky code should look similar to Hal Blinky. The code determines the location of an LED on the board, and if there is an LED it starts by setting it high. The code then enters a loop that will toggle the output level

Threaded Blinky uses the tx_thread_sleep command to wait for 1 second. The parameter passes to tx_thread_sleep is in 'ticks' which are 10ms each, thus 100 is equal to 1 sec.

What's Next

Now that you have completed this example design here are some suggestions for building on this exercise to extend your knowledge and skills with the Synergy Platform.