TI TMS320F280x
Porting Paulus on TI TMS320F280x
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_tms320f280x | 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 |
/ tms320f280x/ | 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) |
/tms320f280x/tms320f280x_flash.[ch] | target-specific flash routines |
/tms320f280x/tms320f280x_can.[ch] | CAN routines |
/tms320f280x/tms320f280x_init.c | CPU initialization |
/tms320f280x/environ.h | header file for the environment includes |
/tms320f280x/bl_config.h | Paulus configuration file |
/tms320f280x/tidcs/.. | F280x Support Library v170 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 “Spectrum Digital TMS320F2808 - eZdSP” from TI with TMS320F2808 and additional a TMS320F2809 CPU in the socket.
The initialization of the CAN controller is done in module tms320f280x_can.c.
In module tms320f280x_init.c the I/O pins for the CAN interface have to be initialized.
In module tms320f280x_init.c there must be the functions getBitRate() and getNodeId() available. Usually the CANopen network parameters are provided by reading jumpers or by loading from flash memory.
Development environment
Paulus on the platform of TMS320F280x was developed with the workbench TI CodeComposer v6.1.2.
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 about the compiler-define BITRATE_INDEX_<bit_rate> in /tms320f280x/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 base on /CiA-305/. The supported CAN bit rates are depending on the clock of the CAN controller and are listed in / tms320f280x / tms320f280x_can.c. The value FFh for segment2 marks unsupported CAN bit rates. The clock for the activation of the CAN bit rate is generated by hardware timer0 with a period of 1 ms.
Heartbeat producer
Timer0 is also used for the generation of Heartbeat producer messages.
Debug output
By the compiler-define DEBUG a debug output can be activated about the serial interface usart. The compiler-define is set in file / tms320f280x /bl_config.h:
#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 in 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_tms320f280x\examples\s1>postBuildStep_Debug.bat
Z:\0\0271\software\examples\CANopenSlave1_tms320f280x\examples\s1>
C:\ti\ccsv6\tools\compiler\ti-cgt-c2000_6.4.6\bin\hex2000.exe –i Debug\s1_tms320f2809.out
Translating to Intel format...
"Debug\s1_tms320f2809.out" codestart ==> codestart
"Debug\s1_tms320f2809.out" .text ==> .text
"Debug\s1_tms320f2809.out" .econst ==> .econst
"Debug\s1_tms320f2809.out" .cinit ==> .cinit
"Debug\s1_tms320f2809.out" .switch ==> .switch
"Debug\s1_tms320f2809.out" .reset ==> .reset
Unused bytes in the application header are set to 0x00 with the TMS320F280x. The length of the application header is 256 bytes.
Example: The download file for the application program s1_tms320f280x.download is generated about Windows console with the prepared script “create_image.bat” (e.g. for tms320f2809 target):
Z:\CANopenSlave1_tms320f280x\examples\s1>create_image.bat
Z:\0\0271\software\examples\CANopenSlave1_tms320f280x\examples\s1>set tools_dir=..\..\..\..\tools
Z:\0\0271\software\examples\CANopenSlave1_tms320f280x\examples\s1>..\..\..\..\tools\objcopy -I ihex -O binary --gap-fill=0xFF s1_tms320f2809.i00 s1_tms320f2809.b00
Z:\0\0271\software\examples\CANopenSlave1_tms320f280x\examples\s1>..\..\..\..\tools\objcopy -I ihex -O binary --gap-fill=0xFF s1_tms320f2809.i01 s1_tms320f2809.b01
Z:\0\0271\software\examples\CANopenSlave1_tms320f280x\examples\s1>..\..\..\..\tools\paulus_cksum -C -l 256 -j -x 0x3D8080 -O s1_tms320f2809.download s1_tms320f2809.b00 s1_tms320f2809.b01
size: 0x00005f74, crc: 0x08cc
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 TMS320F280x 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 tms320f280x/tms320f280x_flash.h are identical. The application software is stored as a separate program in the flash memory additionally to the bootloader program. Therefore the application software is flashed to:
#define FLASH_PROGRAM_START_ADR 0x3D8000
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 tms320f280x/bl_interface.h by the compiler-define BL_JUMPCODE_SIZE.
The shared memory is installed in tms320f280x/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 TMS320F2809 flash is 128Kb. The current implementation of Paulus occupies a memory area of 16Kb (Sector A) from this. Therefore 112Kb (less 0x80 byte crc header) flash memory area available for the application software.
The optionally CANopen service LSS from Paulus used just additional Flash Sector B for saving config data (nodeID and bitrate index). This is only a possible design example. But it’s alternatively possible to store this data in an eeprom to get the Sector B for the application software free.
The flash area for configuration data of Paulus is located at address 0x3F3F80. 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 tms320f280x/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 tms320f280x/bl_config.h.
Example application
CANopen Slave1 is an example for an application program. The directory example/ CANopenSlave1_tms320f280x contain the compiler project and the application-specific functions. For compilation the CANopen Library and the 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_tms320f280x/examples/s1/s1_tms320f2809_download can be used for a quick start.
Additional a simple “hello World” example is available for some targets (/examples/ hello_tms320f2809/ hello_2809.crc). This examples send usart printf output after jumping into this. After some time, the jump back into the boot loader.The linker file of this example project is adapted on these Paulus memory requirements. See flash address settings in the linker-file (memory_example_2809.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