Functional and Hardware Safety is a big thing for the Hercules micro controller family.These controllers have a whole bunch of hardware features that help you deal with failures and exceptions.You may not always be able to fix them, but at the very least you have the ability to detect mishaps and land gracefully, whenever possible.
But there's also software support for safe operations. There's a SafeTI Compliance Support Package for Hercules Diagnostic Library available. My project is focusing on the Safety Self Diagnostics capabilities of that lib.
Self Test ExampleI haven't invented this myself. I'm using the example that comes with HALGoGen. This post will give you some tips and tricks to get the program compiled and running.To get at the HALCoGen instructions, Go to Help -> Help Topics
, and click on example_SafetyLib.c
.
Here are the simplified and improved :) instructions:
First, create a CCS project for your micro controller (in my case TMS570LC43X), and select type Empty Project
.
Then, create a HALCoGen project in the same folder where you created the CCS one. Leave everything as is, just select the right controller and generate the code.In CCS, add the include directory created by HALCoGen to the compiler's include path.
Next, let's add a project variable to hold the location of the Safety Lib:
Now, add the Safety Lib sources to the project. Right click on the project name, and select New -> Folder
.Click on the advanced tab, and then on Link to Alternate Location
.Enter this value: ${SL_INSTALL_PATH}\safety_library\source
Then, add this folder and two additional include file locations of the safety lib to the compiler include settings
You can see that I've consistently used variables, never the physical location of the safety lib.
We also need to define 3 symbols:
_TMS570LC43x_
_VFP_SUPPORT_=1
EXTERNAL_SP_INIT
And one that's not documented in the help file, but required for a successful build:
SL_REG_INIT_VAL=0u
Then there are a few things to do related to the memory check behaviour of the TMS570LC43. First some flash load settings.
Then we need to replace the HALCoGen created linker command file HL_sys_link.cmd
with the one from TI's wiki.
Once that's done, add these two lines to section:
/* USER CODE BEGIN (6) */
LOG_DATA : START( ulLOGStartAddr ), END( ulLOGEndAddr ) > RAM
.sl_stflash_SRAM : RUN = RAM, LOAD = FLASH0|FLASH1, LOAD_START(ulHighHandlerLoadStart), LOAD_END(ulHighHandlerLoadEnd), LOAD_SIZE(ulHighHandlerSize), RUN_START( ulHighHandlerStartAddr ), RUN_END( ulHighHandlerEndAddr )
Overwrite the HALCoGen generated file HL_sys_startup.c
with the code from the help file, and that's it.
To see what's happening, you have to set a breakpoint in HL_sys_startup.c
. Otherwise the debugger goes directly to your main() function and you miss all the goodies.I put one on line 207:
SL_ESM_Init(&esmCallBackFunction);
From then on, you're in safety paradise. Loads of things to learn by stepping through the code and see what all those self diagnose checks are doing.If your Hercules controller is going to be used in a safety critical device, you may want to add the diagnostics to your firmware.
I've made an interactive test bed for the library. You can test the safety mechanisms real-time using the joystick and LCD of the Educational Boosterpack MKII. Here is the blog on element14.
Good Luck!!
Comments
Please log in or sign up to comment.