I have the new Texas Instruments Hercules LaunchPad here at home.

It's the LAUNCHXL2-570LC43LAUNCHXL2-570LC43 with a TMS570LC4357 microcontroller.

 

IMG_5097.JPG

 

That TMS570LC43, an ARM Cortex R5 that can clock up to a whopping 300MHz (the RM57L843 goes up to 330), is targeted to safety and automotive applications.

All peripherals, the memory and the ARM core are designed with that safety in mind.

The processor is actually a dual ARM R5 core, where core 2 runs in lockstep with core 1.

 

lockstep.jpg

 

By comparing the state of both cores at each clock cycle, inconsistencies in the controller can be detected in the hardware, without impacting performance.

If you are into design for safety, it's worth checking out all the measures that are taken in this chip to validate safe operations,
how to recover/correct where possible and fail safely when needed.

 

In this post, I'm creating an ADC project for the LaunchPad. I'm only using on board components. It's a good project when you are taking your first steps with the Hercules series.

 

ADC  sampling with the TMS507LC43/RM57L

 

Based on the Project0 for TMS570LS04

http://www.ti.com/ww/en/launchpad/dl/Hercules_LaunchPad_Proj0.pdf

 

Configure the microcontroller in HALCoGen

 

Create new project

File -> New -> Project

 

Select Device TMS570LC4357ZWT or RM57L843ZWT

When naming the project, take care to use the same name later in CCS, and check that the location is your CCS working directory.

 

 

Enable Drivers

In the Driver Enable tab, select SCI1 and ADC1

SCI1 will be used to do serial communication over the USB COM port.

The potentiometer is connected to ADC1.

 

 

Configure SCI1

In the SCI1 - SCI Data Format tab, validate that the baud rate  is 9600, with 8 bits length and 2 stop bits

 

 

Use the same settings later in your terminal program to monitor the output.

 

Configure ADC1

Set FiFo Size to 1, and enable pin 6 (that's the AD1IN_6 input that we're sampling.

 

 

Generate the Code

All configuration is coomplete. Save the project  and generate the code.

File -> Save Project

File -> Generate Code

 

 

Write your Program in Code Composer Studio

 

Create new project

File -> New -> CCS Project

 

 

Select TMS570LC43xx or RM57L8xx as target.

Use the XDS110 debugger.

Check that the location is the same directory that was used in HALCoGen above.

Choose Empty Project. HALCoGen has already created all source files we need.

 

 

for HALCoGen Versions older than June 2015 only

replace the source/HL_sys_link.cmd file generated by HALCoGen by the one from this url:

http://processors.wiki.ti.com/index.php/LAUNCHXL2-570LC43-RM57L:_LinkerECCRecommendation or check Hercules Microcontroller: Correctly create and load Firmware with Error Checking and Correction (TMS570LC43 and RM57 specific)

 

 

Set the Project Properties

Right click on your project, and select Properies

 

Add the HALCoGen generated include files to the project include path.

 

 

Set the Debug Flash options as documented on the url above.

 

 

Add the Logic to the Main File

Edit the HL_sys_main.c file.

Add these lines between /* USER CODE BEGIN (0) */ and /* USER CODE END */

 

/* USER CODE BEGIN (0) */
#include "HL_sci.h"
#include "HL_adc.h"
#include "stdlib.h"
unsigned char command[8];
/* USER CODE END */
       

 

Add these lines between /* USER CODE BEGIN (3) */ and /* USER CODE END */

 

/* USER CODE BEGIN (3) */
    adcData_t adc_data; //ADC Data Structure
    adcData_t *adc_data_ptr = &adc_data; //ADC Data Pointer
    unsigned int NumberOfChars, value; //Declare variables
    sciInit(); //Initializes the SCI (UART) module
    adcInit(); //Initializes the ADC module
    while(1) // Loop to acquire and send ADC sample data via the SCI (UART)
    {
    adcStartConversion(adcREG1, 1U); //Start ADC conversion
    while(!adcIsConversionComplete(adcREG1, 1U)); //Wait for ADC conversion
    adcGetData(adcREG1, 1U, adc_data_ptr); //Store conversion into ADC pointer
    value = (unsigned int)adc_data_ptr->value;
    NumberOfChars = ltoa(value,(char *)command);
    sciSend(sciREG1, 2, (unsigned char *)"0x"); //Sends '0x' hex designation chars
    sciSend(sciREG1, NumberOfChars, command); //Sends the ambient light sensor data
    sciSend(sciREG1, 2, (unsigned char *)"\r\n"); //Sends new line character
    }
/* USER CODE END */
       

 

Build and Debug your Project

 

 

You can do this in a single step by pushing the Debug icon. If you prefer, you can first use the Build icon next to it.

Your LaunchPad has to be connected via USB before you click Debug.

You can now Resume the program and connect a Serial Terminal program to the LaunchPad's COM port.

The terminal will show the measured values. Turn the potentiometer and see how the measurements change.

 

 

Most Terminal programs with Serial Interface will do.

You'l need to know the COM port of the LaunchPad. On Windows, that's available via the Device Manager.

 

 

For PuTTY, you can set the following

 

 

If you're using the Eclipse Terminal window, use these settings: