T89C51CC01 CAN Bootloader

Similar documents
T89C51CC02 CAN Bootloader

T89C51CC02 CAN Bootloader

T89C51CC01 CAN Bootloader

AT89C51CC03 UART Bootloader

T89C51AC2 UART Bootloader

T89C5115 UART Bootloader

AT89C51CC03 UART Bootloader

AT89C51SND1 UART Bootloader

a clock signal and a bi-directional data signal (SCL, SDA)

AVR32752: Using the AVR32 UC3 Static Memory Controller. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1315: Accessing the XMEGA EEPROM. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT697E. Application Note. Checking AT697E Code for Occurrence of LDF/FPOPd Instructions Sequence with a dependency on an Odd-Numbered Register

Application Note. Microcontrollers. Using Keil FlashMon Emulator with AT89C51CC01/03 AT89C51CC01/ Summary. 2. Background overview

CAN Microcontrollers. Application Note. Migrating from T89C51CC01 to AT89C51CC03. Feature Comparison

AVR1303: Use and configuration of IR communication module. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91 ARM Thumb Microcontrollers. Application Note. Using the ECC Controller on AT91SAM9260/9263 and AT91SAM7SE Microcontrollers. 1.

AVR based 125kHz RFID Evaluation Kit (Re)Programming Guide ATA2270-EK1. Overview. Fuse Settings: ISP Programming

AT89C5131A USB Bootloader

8-megabyte, 4-megabyte, and 2-megabyte 2.7-volt Only DataFlash Cards AT45DCB008D AT45DCB004D AT45DCB002D. Not Recommended for New Design

AVR32401: AVR32 AP7 Linux Interfacing DataFlash. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1922: Xplain Board Controller Firmware 8-bit Microcontrollers Application Note Features 1 Introduction

AVR1503: Xplain training - XMEGA Programmable Multi Interrupt Controller 8-bit Microcontrollers Application Note Prerequisites

AVR097: Migration between ATmega128 and ATmega1281/ATmega bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller with 2K/4K/8K Bytes In-System Programmable Flash. Appendix A. Preliminary. ATtiny261 ATtiny461 ATtiny861 Automotive

Application Note Microcontrollers. C Flash Drivers for T89C51RC/RB/IC2 and AT89C51RC/RB/IC2 for Keil Compilers

AT89C51SND1 USB Bootloader

AT91 ARM Thumb Microcontrollers. Application Note. AT91 Host Flash Loader. 1. Package Contents. 2. Definition of Terms. 3.

AT17F Series. Application Note. Programming Circuits for AT17F Series Configurators with Xilinx FPGAs. 1. Introduction

AVR532: Migration from ATmega48/88/168 to ATmega48A/88A/168A. 8-bit Microcontrollers. Application Note. 1 Introduction

AVR32917: picopower Board getting started. 32-bit Microcontrollers. Application Note. Preliminary. Features. 1 Introduction

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATtiny87 ATtiny167 Automotive

Rad Hard FPGA. AT40KEL-DK Design Kit Content. Description. Kit Content. Reference Material. Support

AVR1501: Xplain training XMEGA Timer/Counter 8-bit Microcontrollers Application Note Prerequisites 1 Introduction

One-channel Toggle-mode Touch Sensor IC with Power Management Functions AT42QT1012. Summary

AT91 ARM Thumb-based Microcontroller. Application Note. AT91SAM7X and AT91SAM7XC Microcontroller Series Schematic Check List. 1.

AT89ISP Programmer Cable Introduction AT89ISP Programmer Cable Parallel Port Settings Application Note AT89ISP Software AT89ISP Cable polarized

CAN, 80C51, AVR, Microcontroller. Application Note

AVR1508: Xplain training - XMEGA DAC 8-bit Microcontrollers Application Note Features 1 Introduction

Migration From AT89C51SND1C to AT83C51SDN1C. Application Note. MP3 Microcontrollers

AVR32901: EVKLCD100/EVKLCD101 Hardware User's Guide. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR320: Software SPI Master

ATDH2200E Programming Kit... User Guide

ATA2270-EK1. User Guide

80C51 MCUs T89C51AC2. Errata Sheet

Interfacing the internal serial EEPROM

4-megabit (512K x 8) 5-volt Only 256-byte Sector Flash Memory AT29C040A

AT89C5131 Starter Kit... Software User Guide

AVR32 UC3 Software Framework... User Manual

APPLICATION NOTE. Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices. Atmel AVR XMEGA. Features.

AVR32015: AVR32 Studio getting started. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

64K (8K x 8) High Speed Parallel EEPROM with Page Write and Software Data Protection AT28HC64BF

1-megabit (128K x 8) 3-volt Only Flash Memory AT29LV010A

APPLICATION NOTE. Atmel AT03304: SAM D20 I 2 C Slave Bootloader SAM D20. Description. Features

512K (64K x 8) 3-volt Only Flash Memory AT29LV512

2-megabit (256K x 8) 5-volt Only Flash Memory AT29C020

2-megabit (256K x 8) Single 2.7-volt Battery-Voltage Flash Memory AT29BV020

AVR ONE!... Quick-start Guide. EVK Windows 32103C AVR ONE! 02/10

Embedded AVR Microcontroller Including RF Transmitter and Immobilizer LF Functionality for Remote Keyless Entry ATA5795. Summary.

SAM Boot Assistant (SAM-BA)... User Guide

T89C51CC01 T89C51CC01UA T89C51CC01CA. Errata Sheet. CAN Microcontrollers

1-megabit (128K x 8) Paged Parallel EEPROM AT28C010

Trusted Platform Module AT97SC3203S. SMBus Two-Wire Interface. Summary

Atmel QT600 Quick Start Guide Touch Solutions

Atmel AVR1926: XMEGA-B1 Xplained Getting Started Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR1619: XMEGA-B1 Xplained Demonstration. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

AVR1518: XMEGA-A1 Xplained Training - XMEGA Clock System. 8-bit Atmel Microcontrollers. Application Note. Prerequisites.

8-bit RISC Microcontroller. Application Note. AVR151: Setup And Use of The SPI

APPLICATION NOTE. Atmel AVR1638: XMEGA RTC Calibration. 8-bit Atmel Microcontrollers. Features. Introduction

Atmel LF-RFID Kit Comparison Chart. Application Note. Atmel LF-RFID Kit Comparison Chart. 1. Description

APPLICATION NOTE. AT03324: Atmel REB212BSMA-EK Quick Start Guide. Atmel MCU Wireless. Introduction

Hardware Prerequisites Atmel Xplained Pro Evaluation Kit Atmel WINC1500 extension USB Micro Cable (TypeA / MicroB)

AT89C5122. Application Note. Preventing Windows XP from Displaying Unknown device Message at Startup

AVR42789: Writing to Flash on the New tinyavr Platform Using Assembly

MARC4. Application Note. Hints and Tips for Hard- and Software Developments with MARC4 Microcontrollers

Atmel AVR32847: Migration from/to the UC3L0 64/32/16 from/to the UC3L0 256/ bit Atmel Microcontrollers. Application Note.

AT89STK-10 Starter Kit... Hardware User Guide

64K (8K x 8) Battery-Voltage Parallel EEPROM with Page Write and Software Data Protection AT28BV64B

TSC695. Application Note. Annulled Cycle Management on the TSC695. References

AT17 Series FPGA. Configuration Memory. Application Note. In-System Programming Circuits for AT17 Series Configurators with Atmel and Xilinx FPGAs

STK521. User Guide B AVR 01/12

AVR501: Replacing ATtiny15 with ATtiny25. 8-bit Microcontrollers. Application Note PRELIMINARY. Features. 1 Introduction

AVR515: Migrating from ATmega48/88/168 and ATmega48P/88P/168P/328P to ATtiny48/88. 8-bit Microcontrollers. Application Note. Features.

8051 Microcontrollers. Application Note. Migration from T89C51RD2 to AT89C51RD2/ED2. Feature Comparison

8-bit Microcontroller. Application Note. AVR030: Getting Started with C for AVR

Preparations. Creating a New Project

APPLICATION NOTE. Atmel AVR116: Wear Leveling on DataFlash. 32-bit Atmel Microcontrollers. Features. Description. Wear leveling

APPLICATION NOTE. Atmel AVR057: Internal RC Oscillator Calibration for ATtiny4/5/9/10/20/40. 8-bit Atmel Microcontrollers. Features.

APPLICATION NOTE. Atmel AT02260: Driving AT42QT1085. Atmel QTouch. Features. Description

RACCOON ISP RACCOON ISP. Author: Gilles Labarre Date: February, Ref: RACCOON Rev: 0.0. Doc Control. 1. Overview. 1.1 Document. 1.

SAM4 Reset Controller (RSTC)

AT91 ARM Thumb Microcontrollers. Application Note. Migrating to an AT91SAM9G20-based System from an AT91SAM9260-based System. 1. Scope. 2.

AVR469: MC301 Hardware User Guide. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

OLED display with pixels resolution Ambient light sensor CPU load Analog filter Quadrature Encoder with push button Digital I/O

ATAVRAUTO User Guide

Section 1 ATAVRAUTOEK1 Getting Started

Native route discovery algorithm

32-bit Secure. AT91SC CT-USB Summary. Microcontrollers. Features

AT94K Series Field Programmable System Level Integrated Circuit. Application Note. FPSLIC Baud Rate Generator

8-bit RISC Microcontroller. Application Note. AVR 305: Half Duplex Compact Software UART

AT03975: Getting Started with SAM L21. Descripton. Features. SMART ARM-Based Microcontroller APPLICATION NOTE

Transcription:

Features Protocol CAN Used as a Physical Layer 7 ISP CAN Identifiers Relocatable ISP CAN Identifiers Autobaud In-System Programming Read/Write Flash and EEPROM Memories Read Device ID Full-chip Erase Read/Write Configuration Bytes Security Setting from ISP Command Remote Application Start Command In-Application Programming/Self-Programming Read/Write Flash and EEPROM Memories Read Device ID Block Erase Read/Write Configuration Bytes Bootloader Start CAN Microcontrollers T89C51CC01 CAN Bootloader Description This document describes the CAN bootloader functionalities as well as the CAN protocol to efficiently perform operations on the on-chip Flash (EEPROM) memories. Additional information on the T89C51CC01 product can be found in the T89C51CC01 datasheet and the T89C51CC01 Errata sheet available on the Atmel web site, www.atmel.com. The bootloader software package (source code and binary) currently used for production is available from the Atmel web site. Bootloader Revision Purpose of Modifications Date Revision 1.0.4 First release 02/12/2001 Revision 1.2.1 Standardization of tasks in source program. 19/03/2007

Functional Description In-System Programming Capability In-Application Programming or Self- Programming Capability Block Diagram The T89C51CC01 Bootloader facilitates In-System Programming and In-Application Programming. In-System Programming allows the user to program or reprogram a microcontroller on-chip Flash memory without removing it from the system and without the need of a pre-programmed application. The CAN bootloader can manage a communication with a host through the CAN network. It can also access and perform requested operations on the on-chip Flash memory. In-Application Programming (IAP) allows the reprogramming of a microcontroller on-chip Flash memory without removing it from the system and while the embedded application is running. The CAN bootloader contains some Application Programming Interface routines named API routines allowing IAP by using the user s firmware. This section describes the different parts of the bootloader. Figure 1 shows the on-chip bootloader and IAP processes. Figure 1. Bootloader Process Description External Host via the CAN Protocol Communication On-chip User Application ISP Communication Management IAP User Call Management Flash Memory Management Flash Memory 2 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader ISP Communication Management User Call Management Flash Memory Management The purpose of this process is to manage the communication and its protocol between the onchip bootloader and an external device (host). The on-chip bootloader implements a CAN protocol (see Section Protocol, page 10). This process translates serial communication frames (CAN) into Flash memory accesses (read, write, erase...). Several Application Program Interface (API) calls are available to the application program to selectively erase and program Flash pages. All calls are made through a common interface (API calls) included in the bootloader. The purpose of this process is to translate the application request into internal Flash Memory operations. This process manages low level accesses to the Flash memory (performs read and write accesses). Bootloader Configuration Configuration and Manufacturer Information The following table lists Configuration and Manufacturer byte information used by the bootloader. This information can be accessed through a set of API or ISP commands. Mnemonic Description Default Value BSB Boot Status Byte FFh SBV Software Boot Vector FCh SSB Software Security Byte FFh EB Extra Byte FFh CANBT1 CAN Bit Timing 1 FFh CANBT2 CAN Bit Timing 2 FFh CANBT3 CAN Bit Timing 3 FFh NNB Node Number Byte FFh CRIS CAN Relocatable Identifier Segment 00h Manufacturer ID1: Family Code ID2: Product Name ID3: Product Revision 58h D7h BBh FFh 3

Mapping and Default Value of Hardware Security Byte The 4 Most Significant Byte (MSB) of the Hardware Byte can be read/written by software (this area is called Fuse bits). The 4 (Least Significant Byte) LSB can only be read by software and written by hardware in parallel mode (with parallel programmer devices). Bit Position Mnemonic Default Value Description 7 X2B U To start in x1 mode 6 BLJB P To map the boot area in code area between F800h-FFFFh 5 Reserved U 4 Reserved U 3 Reserved U 2 LB2 P 1 LB1 U To lock the chip (see datasheet) 0 LB0 U Note: 1. U: Unprogram = 1 P: Program = 0 Security The bootloader has Software Security Byte (SSB) to protect itself from user access or ISP access. The Software Security Byte (SSB) protects from ISP accesses. The command Program Software Security Bit can only write a higher priority level. There are three levels of security: Level 0: NO_SECURITY (FFh) This is the default level. From level 0, one can write level 1 or level 2. Level 1: WRITE_SECURITY (FEh) In this level it is impossible to write in the Flash memory, BSB and SBV. The Bootloader returns ID_ERROR message. From level 1, one can write only level 2. Level 2: RD_WR_SECURITY (FCh) Level 2 forbids all read and write accesses to/from the Flash memory. The Bootloader returns ID_ERROR message. Only a full chip erase command can reset the software security bits. Level 0 Level 1 Level 2 Flash/EEPROM Any access allowed Read only access allowed All access not allowed Fuse bit Any access allowed Read only access allowed All access not allowed BSB & SBV & EB Any access allowed Read only access allowed All access not allowed SSB Any access allowed Write level2 allowed Read only access allowed Manufacturer info Read only access allowed Read only access allowed All access not allowed Bootloader info Read only access allowed Read only access allowed All access not allowed Erase block Allowed Not allowed Not allowed Full chip erase Allowed Allowed Allowed Blank check Allowed Allowed Allowed 4 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Software Boot Vector The Software Boot Vector (SBV) forces the execution of a user bootloader starting at address [SBV]00h in the application area (FM0). The way to start this user bootloader is described in Section Boot Process. Figure 2. Software Boot Vector CAN Bootloader Application User Bootloader [SBV]00h FM1 FM0 FLIP Software Program FLIP is a PC software program running under Windows 9x/2000/XP Windows NT and LINUX that supports all Atmel Flash microcontroller and CAN protocol communication media. Several CAN dongles are supported by FLIP (for Windows). This software program is available free of charge from the Atmel web site. 5

In-System Programming Boot Process Hardware Condition ISP allows the user to program or reprogram a microcontroller s on-chip Flash memory through the CAN network without removing it from the system and without the need of a pre-programmed application. This section describes how to start the CAN bootloader and the higher level protocols over the CAN. The bootloader can be activated in two ways: Hardware condition Regular boot process The Hardware conditions (EA = 1, PSEN = 0) during the RESET falling edge force the on-chip bootloader execution. In this way the bootloader can be carried out whatever the user Flash memory content. As PSEN is an output port in normal operating mode (running user application or bootloader code) after reset, it is recommended to release PSEN after falling edge of reset signal. The hardware conditions are sampled at reset signal falling edge, thus they can be released at any time when reset input is low. 6 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Figure 3. Regular Boot Process Hardware Boot Process RESET Hardware Condition No bit ENBO OT in AUXR1 Register is initialized with BLJB inverted Yes ENBOO T = 1 PC = F800h FCO N = 00h ENBOO T = 0 PC = 0000h Yes BLJB = 1 No ENBO OT = 1 PC = F800h FCO N = F0h Software Boot Process FCO N = 00h No SBV < 7Fh Yes Yes No Start Application Start User Bootloader Start Bootloader 7

Physical Layer CAN Controller Initialization The CAN is used to transmit information has the following configuration: Standard Frame CAN format 2.0A (identifier 11-bit) Frame: Data Frame Baud rate: autobaud is performed by the bootloader Two ways are possible to initialize the CAN controller: Use the software autobaud Use the user configuration stored in the CANBT1, CANBT2 and CANBT3 The selection between these two solutions is made with EB: EB = FFh: the autobaud is performed. EB not equal to FFh: the CANBT1:2:3 are used. CANBT1:3 and EB can be modified by user through a set of API or with ISP commands. The figure below describes the CAN controller flow. Figure 4. CAN Controller Initialization CAN Controller Initialization EB = FFh Yes No Read CANBT1 Value Read CANBT2 Value Read CANBT3 Value CANBTx = FFh x=(1,3) Yes No Configure the CAN Controller CAN Error Yes No Set the CAN Controller in Autobaud Mode Autobaud OK No Yes CAN Macro Initialized 8 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader CAN Autobaud The following table shows the auto baud performance for a point-to-point connection in X1 mode. 8 MHz 11.059 MHz 12 MHz 16 MHz 20 MHz 22.1184 MHz 24 MHz 25 MHz 32 MHz 40 MHz 20K 100K 125K 250K 500K Note: 1M indicates an impossible configuration. CAN Autobaud Limitation The CAN Autobaud implemented in the bootloader is efficient only in point-to-point connection. Because in a point-to-point connection, the transmit CAN message is repeated until a hardware acknowledge is done by the receiver. The bootloader can acknowledge an incoming CAN frame only if a configuration is found. This functionality is not guaranteed on a network with several CAN nodes. 9

Protocol Generic CAN Frame Description Identifier Control Data Identifier: Identifies the frame (or message). Only the standard mode (11-bit) is used. Control: Contains the DLC information (number of data in Data field) 4-bit. Data: Data field consists of zero to eight bytes. The interpretation within the frame depends on the Identifier field. The CAN Protocol manages directly using hardware a checksum and an acknowledge. Note: 11-bit 1 byte 8 bytes max To describe the ISP CAN Protocol, we use Symbolic name for Identifier, but default values are given. Command Description This protocol allows to: Initiate the communication Program the Flash or EEPROM Data Read the Flash or EEPROM Data Program Configuration Information Read Configuration and Manufacturer Information Erase the Flash Start the application Overview of the protocol is detailed in Appendix-A. Several CAN message identifiers are defined to manage this protocol. Identifier Command Effect Value ID_SELECT_NODE Open/Close a communication with a node [CRIS]0h ID_PROG_START Start a Flash/EEPROM programming [CRIS]1h ID_PROG_DATA Data for Flash/EEPROM programming [CRIS]2h ID_DISPLAY_DATA Display data [CRIS]3h ID_WRITE_COMMAND Write in XAF, or Hardware Byte [CRIS]4h ID_READ_COMMAND Read from XAF or Hardware Byte and special data [CRIS]5h ID_ERROR Error message from bootloader only [CRIS]6h It is possible to allocate a new value for CAN ISP identifiers by writing the byte CRIS with the base value for the group of identifier. The maximum value for CRIS is 7Fh and the default CRIS value is 00h. 10 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Figure 5. Identifier Remapping 7FFh CAN Identifiers CAN ISP Identifiers ID_ERROR ID_READ_COMMAND ID_WRITE_COMMAND ID_DISPLAY_DATA ID_PROG_DATA ID_PROG_START ID_SELECT_NODE Group of 7CAN Messages Used for Managing CAN ISP [CRIS]0h 000h Communication Initialization The communication with a device (CAN node) must be opened prior to initiate any ISP communication. To open communication with the device, the Host sends a connecting CAN message (ID_SELECT_NODE) with the node number (NNB) passed in parameter. If the node number passed is equal to FFh then the CAN bootloader accepts the communication (Figure 6). Otherwise the node number passed in parameter must be equal to the local Node Number (Figure 7). Figure 6. First Connection Host Interface Board between PC and CAN Network NNB = FFh (Default Value) Node 1 Figure 7. On Network Connection NNB = 00h Host Interface Board Between PC and CAN Network Node 0 NNB = 01h Node 1 NNB = 03h Node 3 NNB = n Node n 11

Before opening a new communication with another device, the current device communication must be closed with its connecting CAN message (ID_SELECT_NODE). Request From Host Identifier Length Data[0] ID_SELECT_NODE 1 num_node Note: num_node is the NNB (Node Number Byte) to which the Host wants to talk to. Answers From Bootloader Identifier Length Data[0] Data[1] Comment ID_SELECT_NODE 2 boot_version 00h 01h Communication close Communication open Note: Data[0] contains the bootloader version. If the communication is closed then all the others messages won t be managed by bootloader. ID_SELECT_NODE Flow Description Host Bootloader Send Select Node Message with Node Number in Parameter ID_SELECT_NODE Message Wait Select Node OR node select = FFh node select = local node number Time-out 10 ms COMMAND ABORTED state com = com open State com = com open State com = com closed Wait Select Node COMMAND FINISHED ID_SELECT_NODE Message Read Bootloader Version Send Bootloader Version and State of Communication COMMAND FINISHED Example HOST Id_select_node BOOTLOADER Id_select_node identifier length data 01 FF 02 01 01 12 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Programming the Flash or EEPROM Data The ID_PROG_START flow described below shows how to program data in the Flash memory or in the EEPROM data memory. This operation can be executed only with a device previously opened in communication. 1. The first step is to indicate which memory area (Flash or EEPROM data) is selected and the range address to program. 2. The second step is to transmit the data. The bootloader programs on a page of 128 bytes basis when it is possible. The host must take care of the following: The data to program transmitted within a CAN frame are in the same page. To transmit 8 data bytes in CAN message when it is possible 3. To start the programming operation, the Host sends a start programming CAN message (ID_PROG_START) with the area memory selected in data[0], the start address and the end address passed in parameter. Requests from Host Identifier Length Data[0] Data[1] Data[2] Data[3] Data[4] ID_PROG_START 5 00h 01h address_start address_end Notes: 1. Data[0] chooses the area to program: - 00h: Flash - 01h: EEPROM data 2. Address_start gives the start address of the programming command. 3. Address_end gives the last address of the programming command. Answers from Bootloader The device has two possible answers: If the chip is protected from program access an Error CAN message is sent (see Section Error Message Description, page 22). Otherwise an acknowledge is sent. Identifier Length ID_PROG_START 0 The second step of the programming operation is to send data to program. Request from Host To send data to program, the Host sends a programming data CAN message (ID_PROG_DATA) with up to 8 data by message and must wait for the answer of the device before sending the next data to program. Identifier Length Data[0]... Data[7] ID_PROG_DATA up to 8 x... x 13

Answers from Bootloader The device has two possible answers: If the device is ready to receive new data, it sends a programming data CAN message (ID_PROG_DATA) with the result Command_new passed in parameter. If the device has finished the programming, it sends a programming data CAN message (ID_PROG_DATA) with the result Command_ok passed in parameter. Identifier Length Data[0] Description ID_PROG_DATA 1 00h 01h 02h Command OK Command fail Command new data ID_PROG_DATA Flow Description Host Send prog_start message with addresses ID_PROG_START Message Bootloader Wait Prog start OR Wait ERROR ID_ERROR Message Send ERROR SSB = Level 0 Wait Prog Start COMMAND ABORTED ID_PROG_START Message Send ProgStart Send prog_data message with 8 datas ID_PROG_DATA Message Wait Data prog Column Latch Full All bytes received Wait Programming OR Wait COMMAND_N ID_PROG_DATA Message Send COMMAND_NEW_DATA All bytes received Wait COMMAND_OK COMMAND FINISHED ID_PROG_DATA Message Send COMMAND_OK COMMAND FINISHED 14 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Example Programming Data (write 55h from 0000h to 0008h in the flash) identifier control data HOST Id_prog_start 05 00 00 00 00 08 BOOTLOADER Id_prog_start 00 HOST Id_prog_data 08 55 55 55 55 55 55 55 55 BOOTLOADER Id_prog_data 01 02 // command_new_data HOST Id_prog_data 01 55 BOOTLOADER Id_prog_data 01 00 // command_ok Programming Data (write 55h from 0000h to 0008h in the flash)with SSB in write security identifier control data HOST Id_prog_start 04 00 00 00 08 BOOTLOADER Id_error 01 00 // error_security Reading the Flash or EEPROM Data The ID_DISPLAY_DATA flow described below allows the user to read data in the Flash memory or in the EEPROM data memory. A blank check command on the Flash memory is possible with this flow. This operation can be executed only with a device previously opened in communication. To start the reading operation, the Host sends a Display Data CAN message (Id_display_data) with the area memory selected, the start address and the end address passed in parameter. The device splits into block of 8 bytes data to transfer to the Host if the number of data to display is greater than 8 data bytes. Requests from Host Identifier Length Data[0] Data[1] Data[2] Data[3] Data[4] 00h ID_DISPLAY_DATA 5 01h address_start address_end 02h Notes: 1. Data[0] selects the area to read and the operation - 00h: Display Flash - 01h: Blank Check on the Flash - 02h: Display EEPROM data 2. The Address_start gives the start address to read. 3. The Address_end gives the last address to read. Answers from Bootloader The device has two possible answers: If the chip is protected from read access an Error CAN message is sent (see Section Error Message Description, page 22). Otherwise: for a display command the device starts to send the data up to 8 by frame to the host. For a blank check command, the device sends a result OK or the first address not erased. Answer to a read command: Identifier Length Data[n] ID_DISPLAY_DATA n x 15

Answer to a blank check command: Identifier Length Data[0] Data[1] Description ID_DISPLAY_DATA 0 - - Blank Check OK 2 Address_start Flow Description Host Send Display_data Message with Addresses or Blank Check ID_DISPLAY_DATA Message Bootloader Wait Display Data OR SSB = Level 2 Wait ERROR ID_ERROR Message Send ERROR COMMAND ABORTED Blank Command Read Data All Data Read nb Max by Frame OR Wait Data Display ID_DISPLAY_DATA Message Send Data Read Verify Memory All Data Read All Data Read COMMAND FINISHED COMMAND FINISHED OR Blank Check Wait COMMAND_OK COMMAND FINISHED Wait COMMAND_OK ID_DISPLAY_DATA Message ID_DISPLAY_DATA Message Send COMMAND_OK Send COMMAND_OK COMMAND FINISHED 16 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader ID_DISPLAY_DATA Example Display Data (from 0000h to 0008h) identifier control data HOST Id_display_data 05 00 BOOTLOADER Id_display_data 08 55 BOOTLOADER Id_display_data 01 55 00 55 00 55 00 55 08 55 55 55 55 Blank Check identifier control data HOST Id_display_data BOOTLOADER Id_display_data 05 01 00 00 00 00 // Command ok 08 Programming Configuration Information The ID_WRITE_COMMAND flow described below allows the user to program Configuration Information regarding the bootloader functionality. This operation can be executed only with a device previously opened in communication. The Configuration Information can be divided in two groups: Boot Process Configuration: BSB SBV Fuse bits (BLJB and X2 bits) (see Section Mapping and Default Value of Hardware Security Byte, page 4) CAN Protocol Configuration: Note: BTC_1, BTC_2, BTC_3 SSB EB NNB CRIS The CAN protocol configuration bytes are taken into account only after the next reset. To start the programming operation, the Host sends a write CAN message (ID_WRITE_COMMAND) with the area selected, the value passed in parameter. Take care that the Program Fuse bit command programs the 4 Fuse bits at the same time. 17

Requests from Host Identifier Length Data[0] Data[1] Data[2] Description 00h write value in BSB 01h write value in SBV 05h write value in SSB 06h write value in EB ID_WRITE_COMMAND 3 01h 1Ch 1Dh value write value in BTC_1 write value in BTC_2 1Eh write value in BTC_3 1Fh write value in NNB 20h write value in CRIS 3 02h 00h value write value in Fuse bits Answers from Bootloader The device has two possible answers: If the chip is protected from program access an Error CAN message is sent (see Section Error Message Description, page 22). Otherwise an acknowledge Command OK is sent. Identifier Length Data[0] Description ID_WRITE_COMMAND 1 00h Command OK ID_WRITE_COMMAND Flow Description Host Bootloader Send Write_Command ID_WRITE_COMMAND Message Wait Write_Command OR NO_SECURITY Wait ERROR_SECURITY COMMAND ABORTED ID_ERROR Message Send ERROR_SECURITY Write Data Wait COMMAND_OK COMMAND FINISHED ID_WRITE_COMMAND Message Send COMMAND_OK COMMAND FINISHED 18 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Example Write BSB at 88h identifier control data HOST Id_write_command BOOTLOADER Id_write_command 03 01 01 00 00 88 // command_ok Write Fuse bit at Fxh identifier HOST Id_write_command BOOTLOADER Id_write_command control 02 02 01 00 data F0 // command_ok Reading Configuration Information or Manufacturer Information The ID_READ_COMMAND flow described below allows the user to read the configuration or manufacturer information. This operation can be executed only with a device previously opened in communication. To start the reading operation, the Host sends a Read Command CAN message (ID_READ_COMMAND) with the information selected passed in data field. Requests from Host Identifier Length Data[0] Data[1] Description 2 00h 00h 01h 02h 00h 01h 05h 06h 1Ch Read Bootloader version Read Device ID1 Read Device ID2 Read BSB Read SBV Read SSB Read EB Read BTC_1 ID_READ_COMMAND 1Dh Read BTC_2 2 01h 1Eh 1Fh 20h 30h 31h 60h 61h Read BTC_3 Read NNB Read CRIS Read Manufacturer Code Read Family Code Read Product Name Read Product Revision 2 02h 00h Read HSB (Fuse bits) 19

Answers from Bootloader The device has two possible answers: If the chip is protected from read access an Error CAN message is sent (see Section Error Message Description ). Otherwise: the device answers with a Read Answer CAN message (ID_READ_COMMAND). Identifier Length Data[n] ID_READ_COMMAND 1 value Flow Description Host Bootloader Send READ_COM Message ID_READ_COMMAND Message Wait Read_Com OR RD_WR_SECURITY Wait ERROR_SECURITY COMMAND ABORTED ID_ERROR Message Send ERROR_SECURITY Read Data Wait Value of Data COMMAND FINISHED ID_READ_COMMAND Message Send Data Read COMMAND FINISHED Example Read Bootloader Version identifier control data HOST Id_read_command BOOTLOADER Id_read_command 02 00 00 01 55 // Bootloader version 55h Read SBV identifier control data HOST Id_read_command 02 01 01 BOOTLOADER Id_read_command 01 F5 // SBV = F5h Read Fuse bit identifier control data HOST Id_read_command 01 02 BOOTLOADER Id_read_command 01 F0 // Fuse bit = F0h 20 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Erasing the Flash The ID_WRITE_COMMAND flow described below allows the user to erase the Flash memory. This operation can be executed only with a device previously opened in communication. Two modes of Flash erasing are possible: Full Chip erase Block erase The Full Chip erase command erases the whole Flash (32 Kbytes) and sets some Configuration Bytes to their default values: BSB = FFh SBV = FFh SSB = FFh (NO_SECURITY) The Block erase command erases only a part of the Flash. Three Blocks are defined in the T89C51CC01: block0 (from 0000h to 1FFFh) block1 (from 2000h to 3FFFh) block2 (from 4000h to 7FFFh) To start the eras ing operation, the Host sends a write CAN message (ID_WRITE_COMMAND). Requests from Host Identifier Length Data[0] Data[1] Description 00h Erase block0 (0K to 8K) ID_WRITE_COMMAND 2 00h 20h Erase block1 (8K to 16K) 40h Erase block2 (16K to 32K) FFh Full chip erase Answers from Bootloader As the Program Configuration Information flows, the erase block command has two possible answers: If the chip is protected from program access an Error CAN message is sent (see Section Error Message Description, page 22). Otherwise an acknowledge is sent. The full chip erase is always executed whatever the Software Security Byte value is. On a full chip erase command an acknowledge Command OK is sent. Identifier Length Data[0] Description ID_WRITE_COMMAND 1 00h Command OK Example Full Chip Erase identifier control data HOST Id_write_command BOOTLOADER Id_write_command 02 00 FF 01 00 // command_ok 21

Starting the Application The ID_WRITE_COMMAND flow described below allows to start the application directly from the bootloader upon a specific command reception. This operation can be executed only with a device previously opened in communication. Two options are possible: Start the application with a reset pulse generation (using watchdog). When the device receives this command, the watchdog is enabled and the bootloader enters a waiting loop until the watchdog resets the device. Take care that if an external reset chip is used, the reset pulse in output may be wrong and in this case the reset sequence is not correctly executed. Start the application without reset A jump at the address 0000h is used to start the application without reset. To start the application, the Host sends a Start Application CAN message (ID_WRITE_COMMAND) with the corresponding option passed in parameter. Requests from Host Identifier Length Data[0] Data[1] Data[2] Data[3] Description ID_WRITE_COMMAND 2 00h - - 03h 4 01h address Start Application with a reset pulse generation Start Application with a jump at address Answer from Bootloader Example No answer is returned by the device. Start application identifier control data HOST Id_write_command 04 03 01 00 00 BOOTLOADER No answer Error Message Description The error message is implemented to report when an action required is not possible. At the moment only the security error is implemented and only the device can answer this kind of CAN message (ID_ERROR). Identifier Length Data[0] Description ID_ERROR 1 00h Software Security Error 22 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader In-Application Programming/S elfprogramming The IAP allows to reprogram a microcontroller on-chip Flash memory without removing it from the system and while the embedded application is running. The user application can call Application Programming Interface (API) routines allowing IAP. These API are executed by the bootloader. To call the corresponding API, the user must use a set of Flash_api routines which can be linked with the application. Example of Flash_api routines are available on the Atmel web site on the software application note: C Flash Drivers for the T89C51CC01CA for Keil Compilers The Flash_api routines on the package work only with the CAN bootloader. The Flash_api routines are listed in Appendix-B. API Call Process Constraints The application selects an API by setting the 4 variables available when the Flash_api library is linked to the application. These four variables are located in RAM at fixed address: api_command: 1Ch api_value: 1Dh api_dph: 1Eh api_dpl: 1Fh All calls are made through a common interface USER_CALL at the address FFC0h. The jump at the USER_CALL must be done by LCALL instruction to be able to comeback in the application. Before jump at the USER_CALL, the bit ENBOOT in AUXR1 register must be set. The interrupts are not disabled by the bootloader. Interrupts must be disabled by user prior to jump to the USER_CALL, then re-enabled when returning. Interrupts must also be disabled before accessing EEPROM data then re-enabled after. The user must take care of hardware watchdog before launching a Flash operation. For more information regarding the Flash writing time see the T89C51CC01 datasheet. 23

API Commands Read/Program Flash and EEPROM Data Memory Several types of APIs are available: Read/Program Flash and EEPROM data Memory Read Configuration and Manufacturer Information Program Configuration Information Erase Flash Start bootloader All routines to access EEPROM data are managed directly from the application without using bootloader resources. The bootloader is not used to read the Flash memory. For more details on these routines see the T89C51CC01 datasheet sections Program/Code Memory and EEPROM Data Memory Two routines are available to program the Flash: api_wr_code_byte api_wr_code_page The application program loads the column latches of the Flash then calls the api_wr_code_byte or api_wr_code_page see datasheet in section Program/Code Memory. Parameter Settings API Name api_command api_dph api_dpl api_value api_wr_code_byte api_wr_code_page 0Dh - - - Instruction: LCALL FFC0h. Note: No special resources are used by the bootloader during this operation. Read Configuration and Manufacturer Information Parameter Settings API Name api_command api_dph api_dpl api_value api_rd_hsb 08h - 00h return HSB api_rd_bsb 05h - 00h return BSB api_rd_sbv 05h - 01h return SBV api_rd_ssb 05h - 05h return SSB api_rd_eb 05h - 06h return EB api_rd_canbtc1 05h - 1Ch return CANBTC1 api_rd_canbtc2 05h - 1Dh return CANBTC2 api_rd_canbtc3 05h - 1Eh return CANBTC3 api_rd_nnb 05h - 1Fh return NNB api_rd_cris 05h - 20h return CRIS api_rd_manufacturer 05h - 30h return manufacturer id api_rd_device_id1 05h - 31h return id1 24 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Instruction: LCALL FFC0h. At the complete API execution by the bootloader, the value to read is in the api_value variable. Note: API Name api_command api_dph api_dpl api_value api_rd_device_id2 05h - 60h return id2 api_rd_device_id3 05h - 61h return id3 api_rd_bootloader_version 0Eh - 00h return value No special resources are used by the bootloader during this operation. Program Configuration Information Parameter Settings API Name api_command api_dph api_dpl api_value api_clr_bljb 07h - - (HSB & BFh) 40h api_set_bljb 07h - - HSB & BFh api_clr_x2 07h - - (HSB & 7Fh) 80h api_set_x2 07h - - HSB & 7Fh api_wr_bsb 04h - 00h value to write api_wr_sbv 04h - 01h value to write api_wr_ssb 04h - 05h value to write api_wr_eb 04h - 06h value to write api_wr_canbtc1 04h - 1Ch value to write api_wr_canbtc2 04h - 1Dh value to write api_wr_canbtc3 04h - 1Eh value to write api_wr_nnb 04h - 1Fh value to write api_wr_cris 04h - 20h value to write Instruction: LCALL FFC0h. Note: 1. See in the T89C51CC01 datasheet the time required for a write operation. 2. No special resources are used by the bootloader during these operations. Erasing the Flash The T89C51CC01 Flash memory is divided in three blocks of 8K Bytes: Block 0: from address 0000h to 1FFFh Block 1: from address 2000h to 3FFFh Block 2: from address 4000h to 7FFFh These three blocks contain 128 pages. Parameter Settings API Name api_command api_dph api_dpl api_value api_erase_block0 00h 00h - - 25

Instruction: LCALL FFC0h. Note: API Name api_command api_dph api_dpl api_value api_erase_block1 00h 20h - api_erase_block2 00h 40h - 1. See the T89C51CC01 datasheet for the time required for a write operation and this time must be multiplied by the number of pages. 2. No special resources are used by the bootloader during these operations. Starting the Bootloader There are two start bootloader routines possible: 1. This routine allows to start at the beginning of the bootloader or after a reset. After calling this routine the regular boot process is performed and the communication must be opened before any action. No special parameter setting Set bit ENBOOT in AUXR1 register Instruction: LJUMP or LCALL at address F800h 2. This routine allows to start the bootloader with the CAN bit configuration of the application and start with the state "communication open". That means the bootloader will return the message ID_SELECT_NODE with the field com port open. No special parameter setting Set bit ENBOOT in AUXR1 register Instruction: LJUMP or LCALL at address FF00h 26 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Appendix-A Table 1. Summary of Frames from Host Identifier Length Data[0] Data[1] Data[2] Data[3] Data[4] Description Id_select_node (CRIS:0h) 1 num node - - - - Open/Close communication Id_prog_start (CRIS:1h) 5 00h 01h start_address end_address Init Flash programming Init EEPROM programming Id_prog_data (CRIS:2h) n data[0:8] Data to program Id_display_data (CRIS:3h) 5 00h 01h 02h start_address end_address Display Flash Data Blank Check in Flash Display EEPROM Data 00h - - - Erase block0 (0K to 8K) 2 00h 20h - - - Erase block1 (8K to 16K) 40h - - - Erase block2 (16K to 32K) FFh - - - Full-chip Erase 00h - - Write value in BSB Id_write_command (CRIS:4h) 3 01h 01h - - Write value in SBV 05h - - Write value in SSB 06h - - Write value in EB 1Ch value - - Write BTC_1 1Dh - - Write BTC_2 1Eh - - Write BTC_3 1Fh - - Write NNB 20h - - Write CRIS 3 02h 00h value - - Write value in Fuse (HSB) 2 03h 00h - - - Start Application with Hardware Reset 4 01h address - Start Application by LJMP address 27

Table 1. Summary of Frames from Host (Continued) Identifier Length Data[0] Data[1] Data[2] Data[3] Data[4] Description 00h - - - Read Bootloader Version 2 00h 01h - - - Read Device ID1 Id_read_command (CRIS:5h) 2 01h 02h - - - Read Device ID2 00h - - - Read BSB 01h - - - Read SBV 05h - - - Read SSB 06h - - - Read EB 30h - - - Read Manufacturer Code 31h - - - Read Family Code 60h - - - Read Product Name 61h - - - Read Product Revision 1Ch - - - Read BTC_1 1Dh - - - Read BTC_2 1Eh - - - Read BTC_3 1Fh - - - Read NNB 20h - - - Read CRIS 2 02h 00h - - - Read HSB Table 2. Summary of Frames from Target (Bootloader) Identifier Length Data[0] Data[1] Data[2] Data[3] Data[4] Description Id_select_node (CRIS:0h) 2 Boot version 00h - - - communication close 01h - - - communication open Id_prog_start (CIRS:1h) 0 - - - - - Command OK Id_prog_data (CRIS:2h) 1 00h - - - - Command OK 01h - - - - Command fail 02h - - - - Command New Data Id_display_data (CRIS:3h) Id_write_command (CIRS:4h) Id_read_command (CRIS:5h) n n data (n = 0 to 8) Data read 0 - - - - - Blank Check OK 2 first address not blank - - - Blank Check fail 1 00h - - - - Command OK 1 Value - - - Read Value 28 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Table 2. Summary of Frames from Target (Bootloader) (Continued) Identifier Length Data[0] Data[1] Data[2] Data[3] Data[4] Description Id_error (CRIS:6h) 1 00h - - - - Software Security Error 29

Appendix-B Table 3. API Summary Function Name api_rd_code_byte Bootloader Execution api_command api_dph api_dpl api_value no api_wr_code_byte yes 0Dh - - - api_wr_code_page yes 0Dh - - - api_erase block0 yes 00h 00h - - api_erase block1 yes 00h 20h - - api_erase block2 yes 00h 40h - - api_rd_hsb yes 08h - 00h return value api_clr_bljb yes 07h - - (HSB & BFh) 40h api_set_bljb yes 07h - - HSB & BFh api_clr_x2 yes 07h - - (HSB & 7Fh) 80h api_set_x2 yes 07h - - HSB & 7Fh api_rd_bsb yes 05h - 00h return value api_wr_bsb yes 04h - 00h value api_rd_sbv yes 05h - 01h return value api_wr_sbv yes 04h - 01h value api_erase_sbv yes 04h - 01h FFh api_rd_ssb yes 05h - 05h return value api_wr_ssb yes 04h - 05h value api_rd_eb yes 05h - 06h return value api_wr_eb yes 04h - 06h value api_rd_canbtc1 yes 05h - 1Ch return value api_wr_canbtc1 yes 04h - 1Ch value api_rd_canbtc2 yes 05h - 1Dh return value api_wr_canbtc2 yes 04h - 1Dh value api_rd_canbtc3 yes 05h - 1Eh return value api_wr_canbtc3 yes 04h - 1Eh value api_rd_nnb yes 05h - 1Fh return value api_wr_nnb yes 04h - 1Fh value api_rd_cris yes 05h - 20h return value api_wr_cris yes 04h - 20h value api_rd_manufacturer yes 05h - 30h return value api_rd_device_id1 yes 05h - 31h return value 30 T89C51CC01 CAN Bootloader

T89C51CC01 CAN Bootloader Table 3. API Summary (Continued) Function Name Bootloader Execution api_command api_dph api_dpl api_value api_rd_device_id2 yes 05h - 60h return value api_rd_device_id3 yes 05h - 61h return value api_rd_bootloader_version yes 0Eh - 00h return value api_eeprom_busy no - - - - api_rd_eeprom_byte no - - - - api_wr_eeprom_byte no - - - - api_start_bootloader no - - - - api_start_isp no - - - - Document Revision History Changes from 4210C - 12/03 to 4210D - 05/06 Changes from 4210D - 05/06 to 4210E - 03/08 1. Changes to full chip erase command. 1. Update of Bootloader version. 31

Headquarters International Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Atmel Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Atmel Europe Le Krebs 8, Rue Jean-Pierre Timbaud BP 309 78054 Saint-Quentin-en- Yvelines Cedex France Tel: (33) 1-30-60-70-00 Fax: (33) 1-30-60-71-11 Atmel Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Product Contact Web Site www.atmel.com Technical Support Enter Product Line E-mail Sales Contact www.atmel.com/contacts Literature Requests www.atmel.com/literature Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL S TERMS AND CONDI- TIONS OF SALE LOCATED ON ATMEL S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDEN- TAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. 2008 Atmel Corporation. All rights reserved. Atmel, logo and combinations thereof, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.