TI TMS320F28035
Porting Paulus on TI TMS320F28035
File structure
After installation of Paulus the source code is stored in the file structure shown in Table 1 describes the contents.
directory | description |
/paulus_tms320f2803x | project folder with all necessary code composer project files |
/bootloader | target independent CANopen sources for Paulus |
/eds | Design Tool project of Paulus with all generated files, e.g. the EDS file and documentation files |
/tms320f28035/ | target-specific sources of Paulus, e.g. CAN-driver, low-level drivers and supporting services from TI Corporation (e.g. startup, clock, flash-service, usart) |
/tms320f28035/tms320f2803x_flash.[ch] | target-specific flash routines |
/tms320f28035/tms320f2803x_can.[ch] | CAN routines |
/tms320f28035/tms320f2803x_init.c | CPU initialization |
/tms320f28035/environ.h | header file for the environment includes |
/tms320f28035/bl_config.h | Paulus configuration file |
/tms320f28035/tidcs/.. | F2803x Support Library v129 and Flash-API lib from TI |
/examples | example applications for a CANopen slave and simple “hello World” examples with necessary project files |
/tools | checksum generator tool for Paulus |
main.c | main loop of Paulus |
Table 1: File structure
Paulus is implementet und tested on the Board “TMS320C2000 Experimenter Kit” from TI which includes a TMS320F28035 Piccolo. The initialization of the CAN controller is done in the module tms320f2803x_can.c.
In the module tms320f2803x_init.c the I/O pins for the CAN interface are initialized.
Also in the module tms320f2803x_init.c there are the functions getBitRate() and getNodeId() available. Usually the these CANopen network parameters are provided by reading jumpers or by loading from flash memory.
Development environment
Paulus on the platform of TMS320F2805x was developed with the workbench TI CodeComposer v6.2.0.
Paulus configuration
In general the initialization function initializes only the absolutely necessary peripherals like clock system, CAN controller, memory management as needed by Paulus and a timer for Heartbeat or LSS. Nevertheless, there might be situations where it makes sense that Paulus initializes other functionalities which are later used by the application as well. As an example consider the serial interface for debug messages.
CAN bit rate
The CAN bit rate is coded by the index of the CAN bit timing table according to /CiA-305/. The index of the default CAN bit rate is specified with the compiler-define BITRATE_INDEX_<bit_rate> in /tms320f28035/bl_config.h:
#define BL_USED_BITRATE_INDEX BITRATE_INDEX_125K
The default CAN bit rate is 125 kbit/s and can be changed by LSS services. The LSS services are described in /Paulus_man/ and based on /CiA-305/. The supported CAN bit rates are depending on the clock of the CAN controller and are listed in /tms320f28035/ tms320f2803x_can.c. The value FFh for segment 2 marks unsupported CAN bit rates. The clock for the activation of the CAN bit rate is generated by the hardware Timer0 with a period of 1 ms.
Heartbeat producer
Timer0 is also used for the generation of Heartbeat producer messages.
Debug output
With the compiler-define DEBUG a debug output can be activated about the serial interface usart. The compiler-define is set in file /tms320f2803x/bl_config.h: (This may additionally be controlled by project symbol settings.)
#define DEBUG 1
In general the initialization function will initialize only the absolutely necessary peripherals like clock system, CAN controller, memory management as needed by Paulus. Nevertheless, there might be situations where it makes sense that Paulus initializes other functionalities which are later used by the application as well. As an example consider the serial interface for debug messages.
Generating application software
The application software consists of an application header and an application program.
The application program has to be prepared for download by the following steps:
build the application program in binary format
calculate the CRC of the application program, build the application header and generate the application software to download
configure the start address of the application software in Paulus
Paulus checksum
The program paulus_cksum calculates the CRC checksum of the binary application program generates the application header and stores the application header and the application program in a new file. This file can be loaded into the device by Paulus. The application for download must be a binary file. They could e.g. use the CCS tool hex2000.exe to convert a created output file from CCS to hex file as an intermediate step.
Example: call the prepared script “postBuildStep_Debug.bat” from a windows console:
Z:\<..>\CANopenSlave1_tms320f28035\examples\s1>C:\ti\ccsv6\tools\compiler\ti-cgt-c2000_17.9.0.STS\bin\hex2000.exe -i Debug\s1_tms320f28035.out
Translating to Intel format...
"Debug\s1_tms320f28035.out" codestart ==> codestart
warning: Data is being written to auto-generated file s1_tms320f28035.i00
warning: Data is being written to auto-generated file s1_tms320f28035.i01
"Debug\s1_tms320f28035.out" .text ==> .text
"Debug\s1_tms320f28035.out" .econst ==> .econst
"Debug\s1_tms320f28035.out" ramfuncs ==> ramfuncs
"Debug\s1_tms320f28035.out" .cinit ==> .cinit
"Debug\s1_tms320f28035.out" .switch ==> .switch
"Debug\s1_tms320f28035.out" .reset ==> .reset
Unused bytes in the application header are set to 0x00 with the TMS320F28035. The length of the application header is 256 bytes.
Example: The download file for the application program s1_tms320f28035.download is generated with Windows console with the prepared script “create_image.bat”:
Z:\<..>\CANopenSlave1_tms320f28035\examples\s1>create_image.bat
Z:\<..>\CANopenSlave1_tms320f28035\examples\s1>REM
Z:\<..>\CANopenSlave1_tms320f28035\examples\s1>REM hex2000.exe -i debug\s1_tms320f28035.out
Z:\<..>\CANopenSlave1_tms320f28035\examples\s1>REM is called from the CCS post command / alternatively from windows console
Z:\<..>\CANopenSlave1_tms320f28035\examples\s1>set tools_dir=..\..\..\..\tools
Z:\<..>\CANopenSlave1_tms320f28035\examples\s1>..\..\..\..\tools\objcopy -I ihex -O binary --gap-fill=0xFF s1_tms320f28035.i00 s1_tms320f28035.b00
Z:\<..>\CANopenSlave1_tms320f28035\examples\s1>..\..\..\..\tools\objcopy -I ihex -O binary --gap-fill=0xFF s1_tms320f28035.i01 s1_tms320f28035.b01
Z:\<..>\CANopenSlave1_tms320f28035\examples\s1>..\..\..\..\tools\paulus_cksum -C -l 256 -j -x 0x3E8080 -O s1_tms320f28035.download s1_tms320f28035.b00 s1_tm
s320f28035.b01
size: 0x00005f28, crc: 0x0c6c
Besides checking the CRC Paulus checks also the size of the application header. A size of 0 is invalid. An application may destroy the ’valid’ information by overwriting the size with 0. That is always possible on the TMS320F28035 FLASH, because the byte content is 0xFF after erasing.
More detailed information from this tool can find in /Paulus_CRC/.
Start address
It is important that the start address of the application software in the flash memory and the information in the Paulus configuration in tms320f28035/tms320f2803x_flash.h are identical. The application software is stored as a separate program in the flash memory in addition to the bootloader program. Therefore the application software is flashed to:
#define FLASH_PROGRAM_START_ADR 0x3E8000ul
The length of the application header is 256 byte. The program start of the application is at address (FLASH_PROGRAM_START_ADR + 256 bytes).
Memory
Shared RAM
The shared RAM for data exchange between bootloader and application starts at address 0x000000 in the NOINIT section from RAM block M0. The size of the shared RAM is specified in <target>/bl_interface.h by the compiler-define BL_JUMPCODE_SIZE.
The shared memory is installed in tms320f28035/bl_interface.c as follow:
#pragma DATA_SECTION(jumpcode , ".noinit")
UNSIGNED8 jumpcode[BL_JUMPCODE_SIZE];
The keyword for the re-start of the application program is set in byte 0-3 of jumpcode. Paulus uses the keyword “APPL” or “BOOT” to start the application program, see /Paulus_man/.
Flash
The size of the respective flash is dependent on the CPU type. The total size of the TMS320F28035 flash is 64Kb. The current implementation of Paulus occupies a memory area of 16Kb (Sector A and B) from this. Therefor up to 48Kb (less 0x80 byte crc header) flash memory area is available for the application software.
The optionally CANopen service LSS from Paulus used just additional Flash Sector C for saving config data (nodeID and bitrate index). This is only a possible design example. Alternatively, it is possible to store this data in an eeprom to free the Sector C for the application software.
The flash area for configuration data of Paulus is located at address 0x3F2000. On this address and the following Paulus stores the node-ID and the CAN bit rate index during the execution of the LSS service “LSS store configuration“. The addresses are configurable in tms320f28035/bl_interface.h:
Note:
The Lss store command takes some time to perform. When saving the data in the Flash, the entire Flash sector must be deleted. This can take longer than the default timeout of 500ms. The timeout error from the DeviceMonitor can be ignored, in fact the data is stored.
After the next re-start Paulus uses this node-ID and this CAN bit rate index for communication. The new CAN bit rate cannot be activated by NMT-Command Reset Application. If the LSS services are not used, Paulus uses the node-ID and CAN bit rate index configured in tms320f28035/bl_config.h.
Example application
CANopen Slave1 is an example for an application program. The directory example/ CANopenSlave1_tms320f28035 contain the compiler project and the application-specific functions. For compilation the CANopen Library and a suitable driver package is necessary. The CANopen Library and the driver package belong not to the delivery scope of Paulus. The binary application software in example/ CANopenSlave1_tms320f28035/examples/s1/s1_tms320f28035.download can be used for a quick start.
The linker file of this example project is adapted to the Paulus memory requirements. See flash address settings in the linker-file (memory_example_28035.cmd):
This example has included source files bl_interface.c, bl_interface.h from bootloader. The application program can request an update by jumping back into Paulus by writing of the program control command start application program (value 1) on object 1F51h/1. The application program calls the macro BOOTLOADER_JUMP(APPL). This call is implemented in usr_301.c /sdoWrInd(). The application program stores the keyword “APPL” in the shared RAM and jumps into Paulus. Paulus is re-started and stays running until the application program is started by command.
If the example application program is running the CANopen slave starts with his bootup followed by heartbeat messages over the CAN-bus.
References
/CiA-305/ | CANopen Layer Setting Services and Protocols, CiA |
/Paulus_CRC/ | manual “Paulus Checksum Tool”, see file tools/manual_cksum.pdf |
/Paulus_man/ | manual “Paulus User Manual”, see file UserMan_Paulus_Bootloader_e.pdf |
Table 2: References