Download ST9 user guide - STMicroelectronics
Transcript
Table of Contents 4.3 4.4 4.5 4.6 4.7 4.8 STANDARD AND WATCHDOG TIMERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 4.3.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 4.3.2 Timer Application for Periodic Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . 72 4.3.3 Watchdog Application 1: Generating a PWM . . . . . . . . . . . . . . . . . . . . . 73 4.3.4 Watchdog Application 2: Using the Watchdog . . . . . . . . . . . . . . . . . . . . 74 MULTIFUNCTION TIMER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 4.4.1 Generating Two Pulse Width Modulated Waves with One MFT . . . . . . . 79 4.4.2 Generating a Pulse Width Modulated Wave with a Cleaner Spectrum . . 82 4.4.3 Incremental Encoder Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 4.4.4 MFT Application 1: Generating 2 PWMs using Interrupts . . . . . . . . . . . . 86 4.4.5 MFT Application 2: Generating a PWM using DMA . . . . . . . . . . . . . . . . 86 4.4.6 MFT Application 3: Generating a PWM using the DMA Swap Mode . . . 87 SERIAL PERIPHERAL INTERFACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 4.5.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 4.5.2 Static Liquid-Crystal Display Interface Example . . . . . . . . . . . . . . . . . . . 88 4.5.3 EEPROM Serial Interface Example using I²C . . . . . . . . . . . . . . . . . . . . . 91 SERIAL COMMUNICATIONS INTERFACE . . . . . . . . . . . . . . . . . . . . . . . . . . 92 4.6.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 4.6.2 SCI Application 1: Sending Bytes using Interrupts . . . . . . . . . . . . . . . . . 97 4.6.3 SCI Application 2: Sending Bytes using DMA . . . . . . . . . . . . . . . . . . . . . 97 4.6.4 SCI Application 3: Sending and Receiving Bytes using DMA . . . . . . . . . 97 4.6.5 SCI Application 4: Matching Input Bytes . . . . . . . . . . . . . . . . . . . . . . . . . 97 ANALOG TO DIGITAL CONVERTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 4.7.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 4.7.2 Analog Watchdog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 4.7.3 Interrupt Vectoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 4.7.4 ADC Application: A/D Conversions and Analog Watchdog using Interrupts 101 PERIPHERAL INITIALIZATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 4.8.1 initialization Header File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 4.8.2 Peripheral Function File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 5 USING THE DEVELOPMENT TOOLS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 5.1 5.2 5.3 5.4 DEVELOPING IN C LANGUAGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 AVAILABLE TOOLS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 INTRODUCING THE DEVELOPMENT TOOLS . . . . . . . . . . . . . . . . . . . . . . 113 PROGRAM CONFIGURATION AND INITIALISATION . . . . . . . . . . . . . . . . . 113 5.4.1 Writing the Makefile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 5.4.2 Writing the Linker Command File using a Script File . . . . . . . . . . . . . . . 119 5.4.3 Writing the Start-Up File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 5.5 GLOBAL INITIALISATION: CORE AND PERIPHERALS . . . . . . . . . . . . . . . 129 5.5.1 Core Initialisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 5.5.2 Peripheral Initialisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 3/146 1