Contents: Circuit Board upsd DK3300-ELCD Development Board with a upsd3334d-40u6 MCU with Enhanced Graphic LCD RLINK-ST, a USB-based JTAG adapter from Raisonance for debugging with Raisonance Integrate Development Environment (RIDE) ULINK, a USB-based JTAG adapter from Keil for debugging with Keil s uvision Tools. USB Cables and RS232 Cables 110/220V Universal Power Supply Adapter Software and Tools CD s 1) RKit Development Suite CD- Raisonance: Contains o RIDE C-Compiler and Assembler (limited to 4Kbytes code size) o RIDE Debugger Utility (no code size limit) o upsd3300 sample projects and Application Note o Also includes ST s PSDsoft Express software for configuring the Programmable Logic inside the upsd3300 2) DK3300-ELCD CD- STMicroelectronics: Contains o STMicroelectronics Datasheets, Tools, Software,uPSD3300 sample projects, User Manual and Application Notes o Keil uvision 2 Software and support Tools (Demo Version) for upsd (Limited to 2Kbytes code size) Purpose: The demonstration application code is a RIDE based project that shows use of the PWM and ADC function blocks within the upsd3300 device. A pulse width modulated signal output from the PWM circuit is tied to an RC circuit resulting in a DC voltage that is proportional to the pulse width. This DC voltage is input to an ADC channel and is read after each time the pulse width out of the PWM is changed. The PWM setting and the ADC value read is displayed on the LCD. This simple demonstration project will illustrate the powerful software development tools based upon Raisonance RIDE software, and the RLINK-ST adapter, which provides many features for editing, compiling, programming, and debugging a upsd3300 MCU Series from STMicroelectronics. This demo will quickly illustrate the specific features below to give you a feel for their simplicity and capability: Project Compilation and Flash Programming Single-Step Execution and Source-Level Debugging Device Specific Formatted Displays Breakpoints Symbolic Debugging and Variables Watch Code Iteration Instruction Tracing approaching Real-Time performance The exercise takes a few minutes to complete and demonstrates the major steps for creating and debugging a upsd3300 project. Software Installation and Connections: 1. Software Installation Insert the Raisonance disc supplied with DK3300 Development Kit in your CD drive. The auto run will bring up the program installation menu. First Install PSDsoft Express, take all default choices. Next install RIDE, take all default choices. Remove the Raisonance Disc and then insert the DK3300- ELCD Disc from STMicroelectronics in the CD drive. Navigate the screens and bring up Menu page with Copy Device Drivers and Demo Code. Click on it and then Unzip the file pointing to C:\ root directory in your drive. 2. Physical Connections Connect RLINK-ST to your PC/Laptop using the supplied USB cable and let the USB driver install on Windows. Connect RLINK-ST ribbon cable to the JTAG connector on the DK3300-ELCD circuit board. Make sure that the Board is powered up using the Universal Adapter supplied with the kit and ensure that it is functioning. (See that the LCD display shows the text). Make sure that the Jumpers are set correctly. (Refer to appendix-1 at the end for Jumper settings). Demo and Features Evaluation: Launch RIDE from the Windows programs menu (Raisonance Kit 6.1) or from RIDE icon. Next you ll see a blank work area with the RIDE title menu bar as shown here: Open the demo project. In title menu bar click Project, then Open. Next double-click the project named pwm_adc.prj, from the folder: \RIDE\examples\8051\derivatives\st_upsd\upsd3300\dk33 00-elcd\PWM_ADC\pwm_adc.prj The RIDE environment will display with multiple windows and icons. Refer to Figure - 8 for help as you follow along. The left window will show the project files. Click on the + to expand the project component files and then doubleclick on pwm_adc.c to open file (Refer to Figure -2). 3. Compile Project and Program Flash Memory Click Make All. This compiles and builds the project. Start the Debugger by clicking Start. This programs the Flash and refreshes the RIDE environment showing actions in the Debug / Action/Messages Window (See Figure-8 ). The blue line indicates where MCU execution has stopped at the first line of executable code in the main program, now waiting for your debugging command. The RLINK-ST kit, and the DK3300-ELCD Development Board or your own designed circuit board with a upsd3300 MCU is all that is needed to develop code. RIDE s debugger utility can be used to symbolically debug 8051 code generated from most any 8051 compiler. So you have a choice keep your existing 8051 compiler and debug with the RIDE debugger (no code size limit), or upgrade the evaluation version of the RIDE compiler on the CD so you can compile with no limit and debug code all within the RIDE environment. See RIDE CD insert, or http://www.raisonance.com for more information on RIDE and upgrades. 1 4. Single-Step and Source-Level Debugging Click Go to see that program runs full speed with the DK3300-ELCD Display showing the following lines of text: PWM to ADC DEMO PWM = xx ADC = yyy where xx and yyy are changing with each execution of the program loop. Click Reset and the program returns to first line of the main program. Click Step-Over to execute one line of C code. You can scroll down to see more lines of code in the program.
When the blue line is on timer0_init(), click Step-In. The debugger is now in the called function, timer0_init(). Double click Disassembly Code in the left debugger window. This opens a display named, code (pwm_adc) showing both C and Assembly code source instructions. Click Step-Over a few times to see that code execution can be stepped one assembly instruction at a time. Click Reset to return to main program, pwm_adc.c 5. Device Specific Formatted Displays Double-click Main Registers in the left debugger window to show the contents of the MCU core registers (Refer to Figure -3). Double-click Port 1 in the left debugger window to show the current value of the pins in I/O port 1. Go back to the file, pwm_adc.c by clicking on tab at bottom of the main display window (Refer to Figure -8), and expand the window view back to full screen. 6. Breakpoints Four hardware breakpoints are available on upsd3300. Set one breakpoint by clicking on the green dot on the left of the line of code ( printflcd(msg_buff); ). The green dot will turn into and the line highlights in red at the line of code as shown in Figure -8 Click Go, the program will run until hitting breakpoint. Click Go repeatedly. See that the PWM and ADC values displayed on the LCD change after each cycle. You will see increasing values for PWM and decreasing values for ADC each time one loop of code is executed within the while(1) loop construct. 7. Symbolic Debugging and Variables Watch With the mouse, highlight the entire variable name ADC_result, then right-click on it, then select Add Watch to add this variable to the Watch Window which appears at bottom left of the screen (Refer to Figure-8 and Figure-4). Select K the same way and add to the watch window. These variables show the current PWM and ADC values. Set the same Breakpoint as in step-6 above. Click Reset. Click Go and see that the values change in the watch window (Refer to Figure-4). and the LCD Display. Repeat this a couple of times. You will see that for each loop the PWM value changes by 10. Click Reset. 8. Code Iteration Make this code change in Flash memory. Close the Debugger by clicking on (this is same icon that starts the Debugger). Now you are in the editor. Go to the file pwm_adc.c by clicking on its file tab and change the following C code statement from printflcd("pwm to ADC DEMO"); to printflcd("pwm - ADC DEMO"); Click Make All to recompile and rebuild the program. Start the Debugger by clicking Start to re-program this new code into the Flash memory. Click Go and see that the LCD display now shows PWM - ADC DEMO 2 Go back to the editor. Go to the file pwm_adc.c and change the text back to the original: printflcd("pwm to ADC DEMO Click Make All to recompile and rebuild the program. Start the Debugger by clicking Start to re-program this new code into the Flash memory. Click Go and see that the LCD display now shows the original text PWM to ADC DEMO Click Reset. 9. Instruction Tracing, near Real-Time Performance The upsd will rapidly stream a record of all the MCU instruction steps out to the RLINK-ST adaptor. From this data, RIDE will create a formatted file to help you find even the most stubborn bugs, showing a history as deep as 256,000 instruction steps that the MCU has last executed! To enable Trace, select from the title bar Debug then Trace, and select trace Options as shown in Figure -5. Open the Trace Display. Select from the title bar Debug, then Trace, then View. A blank Trace Display will appear. (Refer Figure-6) A Trace Display file can display program source code in both C and Assembly formats. Tracing runs in the background with little impact to real-time performance in this project. Go back to the file pwm_adc.c by clicking on its file tab. Set one breakpoint at the line of code ( printflcd(msg_buff); ) as shown in Figure -8 by clicking on the green dot on the left of the line of code. The green dot will turn into and the line highlights in red. Click Go, and the MCU will run until hitting the breakpoint, then a window will open showing the Assembly source code, as shown in Figure -9. Note that the red line indicates where the breakpoint is set (MCU Program Counter value 01BA), and the blue line indicates the next instruction to execute. Now open the Trace Display window by clicking on the file tab Trace (pwm_adc) as shown in Figure -10. At the bottom of the Trace Display is the last instruction that was executed (MCU Program Counter at 01BA). Above this line is the history of all the instructions that the MCU has executed before hitting the breakpoint. Examining the Trace Display window further, you ll see the source C and Assembly statements at each step to assist you in finding a bug. Go back to the file pwm_adc.c and remove the breakpoint by clicking on the at the left of the code line highlighted in red. Click Go and notice that the LCD display shows continuous changes in the PWM and ADC values as the loop is executed multiple times while tracing is occurring in the background. After about 10 seconds click. Stop. See the messages in the window that records the actions ( Figure -7 ). This window shows the number of nonsequential instructions traced. Open the Trace Display window again, Trace(pwm_adc). At the bottom-left you ll see that over 50,000 MCU instruction steps have been recorded!
V 1.0 Dec. 2004 Conclusion: The example code and the steps clearly demonstrate the powerful firmware development and debugging capabilities of the RIDE environment with RLINK-ST for the upsd DK3300- ELCD Development Board. (Refer to Figure -1): Schematic for the DK3300-ELCD circuit board: http://psmdev.st.com/dk3300-elcd _schematics.pdf Please see our web site for the latest information on upsd products, tools, application notes, and other documentation: http://www.st.com/psm For more information, please see: µpsd33xx Series MCU Datasheet: http://www.st.com/stonline/books/pdf/docs/9685.pdf Application Note AN48-uPSD on the supplied RIDE CD. Get the latest Design Guides on-line at : http://www.st.com/stonline/products/families/memories/p sm/soft_c2.htm Appendix 1 DK3300-ELCD Jumper Descriptions and Default Settings The following Table describes the DK3300-ELCD Jumpers. For the PWM_ADC demo to run properly, verify that JP14 ADC7 is closed, JP3 is set to Fix, and jumper sets JP4, JP5 and JP6 are all closed. See the Schematics for more information regarding the jumpers. Jumper # Description Default settings Comments/ JP1 JTAG Debug I/O Pin Closed Should be closed JP2 Reset Input Select closed in position 1-2 for reset switch. Position 2-3 for RTC reset. JP3 LCD Contrast 2-3 closed (Fix) Normally closed in position 2-3 Position 1-2 used for PWM control JP4 Enhanced LCD Closed Determines if the Enhanced -LCD is on Board JP5 Encoder Connection Normally all 3 closed to enable Encoder This connects the Encoder to Port B. JP6 Keyboard & LED Closed JP7 Enable SPI Closed Normally closed to enable SPI EEPROM JP8 IrDA / Uart1 Select Normally 1-3 and 2-4 Closed to select the RS232 connector 1 Else can be set to position 3-5 and 4-6 to select the IrDA transceiver to be connected to UART1. JP9 SRAM Battery Normally Open JP10 Enable I2C Closed Normally both positions closed to enable I2C access to RTC chip. JP11 Clock Select Closed X2 for Crystal Selects Crystal or Oscillator JP12 Interrupt Select for MCU Normally open. (See DK3300-ELCD schematics) JP14 ADC Channel Select ADC7 ( Positions 15-16) is Closed (Used to map various RTC Interrupt sources to the MCU) 1-IRQ ; 2-PFO2; 3-SQW; 4-PFO1; 5-PBO Selects what ADC channel connects the RC circuit on the board. JP15 PWM RC Constant Normally (position 1-2) is closed. Selects PWM RC constant. position 1-2 is 1ms. JP16 JP18 For connecting UART0 and UART1 in loop back mode Headers for M41ST87 Signals Normally open Can be connected positions 1-2 and 3-4 for loop back. Normally not used 3 Headers can be used to check the signals: 1- ECON 2-TPCLR 3-F32K 4-GND
Figure-1 upsd DK3300-ELCD Development Board Figure-4 Watch Window Figure-5 Trace Options FIGURE-2 PROJECT WINDOW Figure-6 Blank Trace Figure-3 MCU Registers Figure-7 Messages Window 4
Figure-8 RIDE Environment Interface Display Windows and Icons 5
Figure-9 Code View (Disassembly) Figure-10 Trace Display 6