These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!
TIMER/FreqMeasure/abstract.h@0:bf7b9fba3924, 2011-03-20 (annotated)
- Committer:
- frank26080115
- Date:
- Sun Mar 20 05:38:56 2011 +0000
- Revision:
- 0:bf7b9fba3924
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frank26080115 | 0:bf7b9fba3924 | 1 | ******************** (C) COPYRIGHT 2010 NXPSemiconductors ******************* |
frank26080115 | 0:bf7b9fba3924 | 2 | * @file TIMER\FreqMeasure\abstract.txt |
frank26080115 | 0:bf7b9fba3924 | 3 | * @author NXP MCU SW Application Team |
frank26080115 | 0:bf7b9fba3924 | 4 | * @version 2.0 |
frank26080115 | 0:bf7b9fba3924 | 5 | * @date |
frank26080115 | 0:bf7b9fba3924 | 6 | * @brief Description of the TIMER Match example in generating |
frank26080115 | 0:bf7b9fba3924 | 7 | * 2 different frequency signals. |
frank26080115 | 0:bf7b9fba3924 | 8 | ****************************************************************************** |
frank26080115 | 0:bf7b9fba3924 | 9 | * Software that is described herein is for illustrative purposes only |
frank26080115 | 0:bf7b9fba3924 | 10 | * which provides customers with programming information regarding the |
frank26080115 | 0:bf7b9fba3924 | 11 | * products. This software is supplied "AS IS" without any warranties. |
frank26080115 | 0:bf7b9fba3924 | 12 | * NXP Semiconductors assumes no responsibility or liability for the |
frank26080115 | 0:bf7b9fba3924 | 13 | * use of the software, conveys no license or title under any patent, |
frank26080115 | 0:bf7b9fba3924 | 14 | * copyright, or mask work right to the product. NXP Semiconductors |
frank26080115 | 0:bf7b9fba3924 | 15 | * reserves the right to make changes in the software without |
frank26080115 | 0:bf7b9fba3924 | 16 | * notification. NXP Semiconductors also make no representation or |
frank26080115 | 0:bf7b9fba3924 | 17 | * warranty that such application will be suitable for the specified |
frank26080115 | 0:bf7b9fba3924 | 18 | * use without further testing or modification. |
frank26080115 | 0:bf7b9fba3924 | 19 | ****************************************************************************** |
frank26080115 | 0:bf7b9fba3924 | 20 | |
frank26080115 | 0:bf7b9fba3924 | 21 | @Example description: |
frank26080115 | 0:bf7b9fba3924 | 22 | Purpose: |
frank26080115 | 0:bf7b9fba3924 | 23 | This example describes how to use Timer to measure a signal's frequency. |
frank26080115 | 0:bf7b9fba3924 | 24 | Process: |
frank26080115 | 0:bf7b9fba3924 | 25 | 1) Initialize UART0 and display information menu. |
frank26080115 | 0:bf7b9fba3924 | 26 | 2) Ask user to input frequency for a test signal. |
frank26080115 | 0:bf7b9fba3924 | 27 | Configure P1.26 as CAP0.0, P0.6 as MAT2.0. |
frank26080115 | 0:bf7b9fba3924 | 28 | 3) Configure TIMER2 as follow: |
frank26080115 | 0:bf7b9fba3924 | 29 | - Prescale register = 1 us. |
frank26080115 | 0:bf7b9fba3924 | 30 | - Match register = 1 / ((frequency)*1us*2) |
frank26080115 | 0:bf7b9fba3924 | 31 | = 500000 / freuqency |
frank26080115 | 0:bf7b9fba3924 | 32 | - No interrupt, no stop but reset timer counter on match. |
frank26080115 | 0:bf7b9fba3924 | 33 | Configure TIMER0 as follow: |
frank26080115 | 0:bf7b9fba3924 | 34 | - Prescale register = 1 us. |
frank26080115 | 0:bf7b9fba3924 | 35 | - Capture register: channel 0, capture on rising edge, generate interrupt |
frank26080115 | 0:bf7b9fba3924 | 36 | on capture. |
frank26080115 | 0:bf7b9fba3924 | 37 | 4) Configure TIMER0 ISR: |
frank26080115 | 0:bf7b9fba3924 | 38 | - Prepare 5 interrupt times, in which timer counter and prescale are reset, |
frank26080115 | 0:bf7b9fba3924 | 39 | for stable. |
frank26080115 | 0:bf7b9fba3924 | 40 | - After this 5 interrupt times, get the capture value, raise done flag. |
frank26080115 | 0:bf7b9fba3924 | 41 | 5) Start TIMER0 and TIMER2. |
frank26080115 | 0:bf7b9fba3924 | 42 | Wait for done flag, then calculate and print out the measure frequency by: |
frank26080115 | 0:bf7b9fba3924 | 43 | one cycle = capture value * 1us (as TIMER0 configuration). |
frank26080115 | 0:bf7b9fba3924 | 44 | signal frequency = 1/one cycle = 1,000,000 / capture value. |
frank26080115 | 0:bf7b9fba3924 | 45 | Press ESC if we intend to test with other frequencies. |
frank26080115 | 0:bf7b9fba3924 | 46 | TIMER0 and TIMER2 are de-initialized. |
frank26080115 | 0:bf7b9fba3924 | 47 | |
frank26080115 | 0:bf7b9fba3924 | 48 | @Directory contents: |
frank26080115 | 0:bf7b9fba3924 | 49 | \EWARM: includes EWARM (IAR) project and configuration files |
frank26080115 | 0:bf7b9fba3924 | 50 | \Keil: includes RVMDK (Keil)project and configuration files |
frank26080115 | 0:bf7b9fba3924 | 51 | |
frank26080115 | 0:bf7b9fba3924 | 52 | lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example |
frank26080115 | 0:bf7b9fba3924 | 53 | makefile: Example's makefile (to build with GNU toolchain) |
frank26080115 | 0:bf7b9fba3924 | 54 | freqmeasure.c: Main program |
frank26080115 | 0:bf7b9fba3924 | 55 | |
frank26080115 | 0:bf7b9fba3924 | 56 | @How to run: |
frank26080115 | 0:bf7b9fba3924 | 57 | Hardware configuration: |
frank26080115 | 0:bf7b9fba3924 | 58 | This example was tested on: |
frank26080115 | 0:bf7b9fba3924 | 59 | Keil MCB1700 with LPC1768 vers.1 |
frank26080115 | 0:bf7b9fba3924 | 60 | These jumpers must be configured as following: |
frank26080115 | 0:bf7b9fba3924 | 61 | - VDDIO: ON |
frank26080115 | 0:bf7b9fba3924 | 62 | - VDDREGS: ON |
frank26080115 | 0:bf7b9fba3924 | 63 | - VBUS: ON |
frank26080115 | 0:bf7b9fba3924 | 64 | - Remain jumpers: OFF |
frank26080115 | 0:bf7b9fba3924 | 65 | IAR LPC1768 KickStart vers.A |
frank26080115 | 0:bf7b9fba3924 | 66 | These jumpers must be configured as following: |
frank26080115 | 0:bf7b9fba3924 | 67 | - PWR_SEL: depend on power source |
frank26080115 | 0:bf7b9fba3924 | 68 | - DBG_EN : ON |
frank26080115 | 0:bf7b9fba3924 | 69 | - Remain jumpers: OFF |
frank26080115 | 0:bf7b9fba3924 | 70 | |
frank26080115 | 0:bf7b9fba3924 | 71 | Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) |
frank26080115 | 0:bf7b9fba3924 | 72 | 115200bps |
frank26080115 | 0:bf7b9fba3924 | 73 | 8 data bit |
frank26080115 | 0:bf7b9fba3924 | 74 | No parity |
frank26080115 | 0:bf7b9fba3924 | 75 | 1 stop bit |
frank26080115 | 0:bf7b9fba3924 | 76 | No flow control |
frank26080115 | 0:bf7b9fba3924 | 77 | |
frank26080115 | 0:bf7b9fba3924 | 78 | Running mode: |
frank26080115 | 0:bf7b9fba3924 | 79 | This example can run on RAM/ROM mode. |
frank26080115 | 0:bf7b9fba3924 | 80 | |
frank26080115 | 0:bf7b9fba3924 | 81 | Note: If want to burn hex file to board by using Flash Magic, these jumpers need |
frank26080115 | 0:bf7b9fba3924 | 82 | to be connected: |
frank26080115 | 0:bf7b9fba3924 | 83 | - MCB1700 with LPC1768 ver.1: |
frank26080115 | 0:bf7b9fba3924 | 84 | + RST: ON |
frank26080115 | 0:bf7b9fba3924 | 85 | + ISP: ON |
frank26080115 | 0:bf7b9fba3924 | 86 | - IAR LPC1768 KickStart vers.A: |
frank26080115 | 0:bf7b9fba3924 | 87 | + RST_E: ON |
frank26080115 | 0:bf7b9fba3924 | 88 | + ISP_E: ON |
frank26080115 | 0:bf7b9fba3924 | 89 | |
frank26080115 | 0:bf7b9fba3924 | 90 | (Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with |
frank26080115 | 0:bf7b9fba3924 | 91 | LPC1000CMSIS project" for more information) |
frank26080115 | 0:bf7b9fba3924 | 92 | |
frank26080115 | 0:bf7b9fba3924 | 93 | Step to run: |
frank26080115 | 0:bf7b9fba3924 | 94 | - Step 1: Build example. |
frank26080115 | 0:bf7b9fba3924 | 95 | - Step 2: Burn hex file into board (if run on ROM mode) |
frank26080115 | 0:bf7b9fba3924 | 96 | - Step 3: Connect UART0 on this board to COM port on your computer |
frank26080115 | 0:bf7b9fba3924 | 97 | - Step 4: Configure hardware and serial display as above instruction |
frank26080115 | 0:bf7b9fba3924 | 98 | - Step 5: Run example |
frank26080115 | 0:bf7b9fba3924 | 99 | Use a wire connect P0.6 and P1.26 |
frank26080115 | 0:bf7b9fba3924 | 100 | Use PC's terminal to select the test signal on P0.26 and see |
frank26080115 | 0:bf7b9fba3924 | 101 | the result measured frequency printed out. |
frank26080115 | 0:bf7b9fba3924 | 102 | (Pls see "LPC17xx Example Description" document - chapter "Examples > TIMER > FreqMeasure" |
frank26080115 | 0:bf7b9fba3924 | 103 | for more details) |
frank26080115 | 0:bf7b9fba3924 | 104 | |
frank26080115 | 0:bf7b9fba3924 | 105 | @Tip: |
frank26080115 | 0:bf7b9fba3924 | 106 | - Open \EWARM\*.eww project file to run example on IAR |
frank26080115 | 0:bf7b9fba3924 | 107 | - Open \RVMDK\*.uvproj project file to run example on Keil |