2.5 Hercules How to Tutorial: Turning on the LEDs

[MUSIC PLAYING] Hello, I'm Anthony Vaughan with the product marketing team for Texas Instrument's Hercules Safety Microcontroller group. Today, I'm going to show you how to configure the general purpose I/O module using HALCoGen, TI's tool for generating initialization and peripheral driver code for Hercules Microcontrollers.
If you do not already have HALCoGen, you can download it from the Tools and Software area on the website ti.com/hercules. HALCoGen can also be installed directly from the software DVD that's included in all Hercules USB Development Stick and Hercules Development Kits.
In this exercise, we're going to use HALCoGen to generate code to turn on all the NHET LEDs on the Hercules development board. For this exercise, we will need a Windows PC, either the TMS570LS31, an RM48 USB stick, or Hercules Development Kit. We will also need HALCoGen and Code Composer Studio.
To start the HALCoGen application, go to the Windows Start menu and select Programs, Texas Instruments, Hercules, HALCoGen. Then to start a new HALCoGen project, select File, New, Project. Once the New Project window has opened, the device family and specific device must be selected. Then the Name of the project can be entered along with the Location for all the generated code to be stored.
So to get started with HALCoGen, we choose File, New, Project, selecte our device. For this example, we'll be using the TMS570LS31 USB. Then we give our project a Name. We'll call this one GIO.
We'll leave the Location set to C:/myworkspace. And we'll also set the Tools to Texas Instruments Tools, since we'll be using the Code Composer Studio compiler. And then we select OK. And then we tell it it's OK to create a new directory for us.
Now that we've got our project loaded, we see a block diagram view of the microcontroller. For this specific example, the only configuration we need to make in HALCoGen is enabled the general purpose I/O or GIO driver. To do that, we go to the Driver Enable tab. Then we deselect all of the drivers and then come in and select just the GIO driver. That's the only configuration we need to do in HALCoGen for this exercise.
The next step is to generate our code by going to File, Generate Code. We can see that all of our files have been created for us by HALCoGen. And they are viewable in the Device Explorer on the right side of the screen. We can go inside and open these files to view them if we want. But to compile them, we'll need to use Code Composer Studio. We'll do that now.
So inside Code Composer, the first step is to create a new project. We do that by selecting File, New, CCS Project. Then we give the project a Name. And we give it the same name that we used inside HALCoGen.
The next step is to configure the device. The default family is ARM, which is correct. Then the next option, we choose Cortex-R inside the Variant field and then choose the specific device we're going to be using, which, in this case, is TMS570LS3137.
The last step in this window is to configure the Connection type. We're going to choose Texas Instruments XDS100 version 2 USB emulator, since that's the JTAG emulator that's included on our development board. Then we click Finish. That will create our project viewable in the Project Explorer on the left hand side of the screen.
The next step is to expand that project, find the main.c file and delete it. Code Composer Studio will always create this file for us when we create a new project. But we don't need it, since we're going to be using the files that HALCoGen created for us.
The next step is to configure a few properties in our project. We do that by selecting the Project, Right Clicking, and choosing Properties. This will bring up a window with many options.
We first need to select the Include Options, so that we include all the header files that HALCoGen created for us. We click the Add button, choose the Workspace, expand our project out, and choose the Include directory, and click OK. Then click OK.
The next step is to make a change to the flash memory programming settings. We choose TMS570 Flash Settings from the Debug menu and change the Erase Options from Erase Entire Flash to Necessary Sectors Only for Program Load. Then click Apply and OK. For small projects, this will speed up flash erase and program significantly.
The next step in our Project Explorer window is to expand Source and open the file sys_main.c. This is where our main function is included. Inside this program, we need to insert some code.
Inside the USER CODE BEGIN (0) section, we're going to include our header file. I've got this code pre-typed, so I can just copy and paste. So we're going to include our het.h header file.
Then the next section we need to include is in USER CODE BEGIN (3), which is actually inside the main function. And we're going to include some code here that sets up our High-End Timer module. So we use the gioSetDirection.
And we call the hetPORT1 and configure all of the hetPORT pins to be outputs. Then we call the gioSetBit function multiple times, and include different pins on the High-End Timer module, and set them all high. This will turn on all the LEDs on our development board.
The last section that we need to insert code in is in the USER CODE BEGIN (4) section. Inside here, we need to insert some code that handles interrupts, if we were using them. Without this code, our project would fail to compile. That's all of the code that we need to insert.
Now, it's time to compile and program our code into the microcontroller. To do this, we select Run and choose Debug. Then it's going to ask us to save the changes that we made to our sys_main.c file. We click OK. And then it will compile and program the microcontroller.
Now that we've programmed our application into the flash memory of the microcontroller, we can now Run it. And we see that our application has run and all of the LEDs have come on on the board.
There are a number of online resources available where you can go to get more information about Hercules Microcontrollers. The first is the Hercules web pages that are on ti.com. Here, you can download official device data sheets, technical reference manuals, and application notes. You can download software like HALCoGen, NowFlash, and the High-End Timer integrated development environment. You can also order development kits through the TI eStore from these web pages.
The next online resource that is at your disposal is the TI engineer-to-engineer Support Forum. Here, you can find the latest news and announcements about Hercules MCUS. In addition to searching for technical content about Hercules, there is a team of applications engineers available to answer questions posted to this forum.
The final web-based resource is the Hercules Wikis. These sites feature how-to guides, introduction videos, and general information about Hercules MCUs. The Wikis contain useful information, like development kit board schematics and training content. I hope that you have found this video useful. Thank you for watching.
[MUSIC PLAYING]

Description

March 10, 2015

This ‘How to Tutorial’ video highlights the General Purpose I/O module (GIO) integrated into many Hercules Safety MCUs. It walks the viewer through an overview of the module and shows how to create initialization code along with a customized peripheral driver for the GIO using HALCoGen. Code Composer Studio is then used to create and deploy a project using the GIO module on the Hercules USB Development Stick Kit that turns on all the LEDs on the board.

1Hercules Safety MCU Architecture Overview (5)

This section provides an introduction to the system architecture of the Hercules Safety Microprocessor.