530 likes | 683 Views
C868 Hands On Training Software Development Tools. January 2003. Infineon. N e v e r s t o p t h i n k i n g. Contents. Software Development Cycle Tool Installation Exercise 1 DAvE Keil Tool Chain Mini-Debugger and Evaluation Board Advanced Topics Enabling and Using XRAM
E N D
C868 Hands On Training Software Development Tools January 2003 Infineon N e v e r s t o p t h i n k i n g .
Contents • Software Development Cycle • Tool Installation • Exercise 1 • DAvE • Keil Tool Chain • Mini-Debugger and Evaluation Board • Advanced Topics • Enabling and Using XRAM • Using the Keil ISD-51 Debugger • Storing a Program in the evaluation board EEPROM • Trouble Shooting
Toolchain and Workflow Free Infineon Provided Tool C Files 3rd Party Tool DAvE Compiler & EDE Hex File Bug Fixes COM Port RS232 Loader COM Port RS232 Evaluation Board or Target Hardware
Installing the Tools • Even though tools are provided with the CD-ROM that is included with the evaluation board, it is usually best to download the latest versions from the web • DAvE • Install DAvE from DAvE CD-ROM • or the DAvE mother system can be downloaded from the DAvE website (www.infineon.com/DAvE) • Add C868 Update to DAvE (www.infineon.com/DAvE) • Use the View | Setup Wizard menu from the DAvE pull-down Menus to install the latest C868 module • Install Latest Keil 8051 Tools (www.keil.com) • Free Demo version (limited to 2k of Code) is available on the web
Installing the Tools • Install the C868 Command Line Mini-Debugger from the Infineon Website (www.infineon.com/cgi/ecrm.dll/ecrm/scripts/prod_ov.jsp?oid=30553&cat_oid=-8136) • This is a command line interface that can download code into the C868 on-chip SRAM • Install the C868 Loader program from the Infineon Website (www.infineon.com/cgi/ecrm.dll/ecrm/scripts/prod_ov.jsp?oid=30553&cat_oid=-8136) • This is a Windows based program that can download code into the C868 on-chip SRAM or the on-board EEPROM
Exercise 1 –Project Settings 3 5 4 2 Crystal Frequency on Evaluation Board 1 Maximum CPU Frequency
Exercise 1 –Disable the Watchdog Timer 2 1 3 5 4
Exercise 1 –Configure all Pins of Port 3 as Output Pins 2 1 5 4 3
Exercise 1 –Select the Initialization Function for the Ports 2 1
Exercise 1 –Generate the Code 1 Store the code in a new directory. The preferred directory is:C:\C868HOT\Exercise1\
Exercise 1 –Double Click on the DAvE Project File (.dpt) • From the Windows Explorer find the .dpt file and double click it • The Keil Tools will automatically Open and a Vision2 Project will be created
Exercise 1 –Set the Project Options 2 4 5 1 3 6 7
Exercise 1 –Set the Project Options 1 5 4 2 6 Place here the path information where the Command line based tool for downloading to SRAM is installed CmdLV103.EXE e.g. C:\Program Files\Infineon\CmdLV103\Bin\
Exercise 1 –Add User Code to the Project 1 2 4 3 5
Exercise 1 –Setup the Evaluation Board • Connect DB-9 Connector to the COM port on your PC • Connect a 9V Battery to the board
Exercise 1 –Build the Project to Create a hex file 1 If there are any errors or warnings, then correct them before proceeding
Exercise 1 –Step 3: Using the Loader to Download Code 1 Download to SRAM usingLoad Button and the command line Mini-Debugger
Advanced Topics Enabling and Using the extra 256 bytes of on-chip XRAM
- - EALE RMAP - - - XMAP0 XRAM • In addition to the standard 256 Bytes of Internal Memory (directly and indirectly accessible with “MOV” instructions), the C868 also has an extra 256 Bytes of XRAM (indirectly accessible with “MOVX” instructions). • To Use the XRAM, bit XMAP0 in the SYSCON0 register must be cleared (it is set after reset). • The Assembly Startup File must be modified to Enable the XRAM (clear XMAP0) and to initialize it so that variables from the C-program are initialized properly SYSCON0 – Address: 0xAD Reset Value: XX10XXX1
Modify the Assembly Startup File to Clear the XRAM This is the Address and Length of the on-chip XRAM This step makes sure that the XRAM is cleared before our C code runs
Modify the Assembly Startup File to Enable the XRAM 0ADh is the address of the SYSCON0 Register This enables the on-chip XRAM
Tell the Linker that you now have XRAM 3 1 4 5 Code Range: 0x0000- 0x1fff XDATA Range: 0xff0b-0xffff (because ISD51 needs 10bytes of XRAM)
Advanced Topics Using the Keil ISD-51 Debugger NOTE: XRAM should be enabled before continuing (see previous section)
Keil ISD-51 Debugger • Keil provides an In-System Debugger for the C868 • The Debugger uses a small monitor program that must be included into your Vision2 project • Once the code is running on your board, you can connect to the debugger via the UART • The debugger allows you to • View variables, arrays and structures • Single Step through the Code • Set Break-points
Add ISD-51 Source Files to Your Project • Copy the Files ISD51.a51 and ISD51.h to your Project Directory
Include ISD51.a51 into your Project 3 1 (right mouse Click) 4 5 2
Enable the UART In you DAvE Project 2 3 7 5 4 6 1
Set the Baud Rate (using T2) to 9600 2 5 3 6 1 4
The Keil Vision2 Project Now has 2 More Source Files If you get this Message Box, Click Yes to Migrate the DAvE changes
Modify main() to Initialize the ISD-51 Debugger 3 2 1 If there are any errors or warnings, then correct them before proceeding
Set the Debugger Options 1 (right mouse Click) 2
Set the Debugger Options 1 3 2 5 4 6 7 8 9 10
Download the Code Then Close the COM Port 1 Disconnect and then Re-connect the battery on your board First! 1 Download to SRAM using Load Button and MiniDebugger Utilities 2 3 4
Advanced Topics Storing a Program in the evaluation board EEPROM See Application Note AP08006 for details
Boot-Strap Loader • The C868 Bootstrap Loader works in the following way • Application Code must contain a way to change the 1st byte of the EEPROM or Re-Programming will be difficult Read 1st Byte from off- chip Serial EEPROM no 1st Byte = 0xA5? yes Load EEPROM Code into on-chip SRAM Start UART Bootstrap Loader
Boot-Strap Loader • For the Bootstrap Loader to automatically load the SRAM from the EEPROM, the serial EEPROM must have a 0xA5 programmed into address 0x0000. • Using the Loader the application code can be programmed into the EEPROM and the first byte can be set to 0xA5. • To Re-Program the EEPROM, the EEPROM must not have a 0xA5 at address 0x0000. • The Application Code must have the ability to erase the first byte of the EEPROM so that the UART Bootstrap Loader (and the mini-debugger) can be started
3 4 5 Add the File ERASE_0.c to your Project • The File EEPROM.c should be included with this presentation. If it is not, the contents of the file are shown it the next slide so you can create the file by cutting and pasting. • Copy the File EEPROM.c into your project Directory • Add the file to you Vision2 Project 1 (right mouse Click) 2
Contents of File ERASE_0.c #include "Main.h" #define WRITE_CMD 0x02 #define WRITE_ENABLE 0x06 void ShiftByteOut(unsigned char TX_Byte) { unsigned char i; for (i=128; i!=0; i=i/2) { P1_1 = 0; // CLK high P1_2 = i & TX_Byte; P1_1 = 1; // CLK Low } } void EraseByte0(void) { SYSCON0 |= 0x10; P1DIR &= 0xF1; // Set P1_1, P1_2 & P1_3 to Outputs SYSCON0 &= ~0x10; P1 |= 0x0A; // Set CS inactive, SCLK High, Data Low P1_3 = 0; // Activate Chip Select on EEPROM ShiftByteOut(WRITE_ENABLE); // Send Write Enable Command P1_3 = 1; P1_3 = 0; ShiftByteOut(WRITE_CMD); // Send Write Command ShiftByteOut(0x00); // Send Address (0x0000) ShiftByteOut(0x00); ShiftByteOut(0x00); // Send Data (0x00) P1_3 = 1; // DeActivate Chip Select on EEPROM while(1); // Wait for external hardware reset }
Build the Project You should get only this one warning since the code in ERASE_0.c is not called
Program the Serial EEPROM 1 Disconnect and then Re-connect the battery on your board First! Copy Tool “Loader.EXE” into Project directory and Start 2 3 4 5 6
Use the Keil Debugger when you want to Re-Program 1 3 Jump to Function to that Erases address 0x0000 2