These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!
DAC/WaveGenerate/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 DAC\WaveGenerate\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 example to generate sinewave, triangle, |
frank26080115 | 0:bf7b9fba3924 | 7 | * escalator signal by DAC. |
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 DMA to generate multi signal forms. |
frank26080115 | 0:bf7b9fba3924 | 24 | Process: |
frank26080115 | 0:bf7b9fba3924 | 25 | DAC will be initialized with maximum current is 700uA. This allows a maximum update rate of 1Mhz |
frank26080115 | 0:bf7b9fba3924 | 26 | Formula for ouput voltage on AOUT is: |
frank26080115 | 0:bf7b9fba3924 | 27 | AOUT = VALUE x ((Vrefp - Vrefn)/1024)+Vrefn |
frank26080115 | 0:bf7b9fba3924 | 28 | in which: |
frank26080115 | 0:bf7b9fba3924 | 29 | - Vrefp: tied to VDD(3.3V) |
frank26080115 | 0:bf7b9fba3924 | 30 | - Vrefn: tied to Vss |
frank26080115 | 0:bf7b9fba3924 | 31 | |
frank26080115 | 0:bf7b9fba3924 | 32 | DAC will generate a sinewave with peak to peak is within Vrefp and Vrefn. We need to prepare a |
frank26080115 | 0:bf7b9fba3924 | 33 | look up table with 60 items, each item is the value to update AOUT voltage, and it's correspondent |
frank26080115 | 0:bf7b9fba3924 | 34 | to a sample point of 1 circle sinewave signal. The formula is below: |
frank26080115 | 0:bf7b9fba3924 | 35 | for(i=0;i<NUM_SAMPLE_SINE;i++) //NUM_SAMPLE_SINE = 60 |
frank26080115 | 0:bf7b9fba3924 | 36 | { |
frank26080115 | 0:bf7b9fba3924 | 37 | dac_lut[i] = 512 + 512*sin(i); |
frank26080115 | 0:bf7b9fba3924 | 38 | dac_lut[i] = (dac_sine_lut[i]<<6); |
frank26080115 | 0:bf7b9fba3924 | 39 | } |
frank26080115 | 0:bf7b9fba3924 | 40 | For generating triangle wave signal, the following formula is used: |
frank26080115 | 0:bf7b9fba3924 | 41 | for(i=0;i<NUM_SAMPLE;i++) //NUM_SAMPLE=64 |
frank26080115 | 0:bf7b9fba3924 | 42 | { |
frank26080115 | 0:bf7b9fba3924 | 43 | if(i<32) dac_lut[i]= 32*i; |
frank26080115 | 0:bf7b9fba3924 | 44 | else if (i==32) dac_lut[i]= 1023; |
frank26080115 | 0:bf7b9fba3924 | 45 | else dac_lut[i] = 32*(NUM_SAMPLE-i); |
frank26080115 | 0:bf7b9fba3924 | 46 | dac_lut[i] = (dac_lut[i]<<6); |
frank26080115 | 0:bf7b9fba3924 | 47 | } |
frank26080115 | 0:bf7b9fba3924 | 48 | This will create a balance triangle. |
frank26080115 | 0:bf7b9fba3924 | 49 | Below is the formula for escalator case: |
frank26080115 | 0:bf7b9fba3924 | 50 | for(i=0;i<NUM_SAMPLE;i++) //NUM_SAMPLE=64 |
frank26080115 | 0:bf7b9fba3924 | 51 | { |
frank26080115 | 0:bf7b9fba3924 | 52 | dac_lut[i] = (1023/3)*(i/16); |
frank26080115 | 0:bf7b9fba3924 | 53 | dac_lut[i] = (dac_lut[i]<<6); |
frank26080115 | 0:bf7b9fba3924 | 54 | } |
frank26080115 | 0:bf7b9fba3924 | 55 | This will create an escalator with 4 steps. |
frank26080115 | 0:bf7b9fba3924 | 56 | |
frank26080115 | 0:bf7b9fba3924 | 57 | GPDMA channel 0 is configured in this example and used to transfer dac_lut[i] to DAC peripheral. |
frank26080115 | 0:bf7b9fba3924 | 58 | When the last item of dac_lut is transfered, GPDMA will roll back to transfer the first item. |
frank26080115 | 0:bf7b9fba3924 | 59 | |
frank26080115 | 0:bf7b9fba3924 | 60 | DAC is configured to use time out for each DAC value update and trigger GPDMA to fill DAC value register. |
frank26080115 | 0:bf7b9fba3924 | 61 | This time out value can also be used to calculate the signal frequency: |
frank26080115 | 0:bf7b9fba3924 | 62 | time out = (PCLK_DAC_IN_MHZ*1000000)/(SIGNAL_FREQ_IN_HZ*NUM_SAMPLE); |
frank26080115 | 0:bf7b9fba3924 | 63 | Where: - PCLK_DAC_IN_MHZ = 25 |
frank26080115 | 0:bf7b9fba3924 | 64 | - SIGNAL_FREQ_IN_HZ = 60 |
frank26080115 | 0:bf7b9fba3924 | 65 | - NUM_SAMPLE = 60 / 64 |
frank26080115 | 0:bf7b9fba3924 | 66 | |
frank26080115 | 0:bf7b9fba3924 | 67 | UART0 will display a menu, asks user to select the signal to generate: |
frank26080115 | 0:bf7b9fba3924 | 68 | 1) Sine |
frank26080115 | 0:bf7b9fba3924 | 69 | 2) Triangle |
frank26080115 | 0:bf7b9fba3924 | 70 | 3) Escalator |
frank26080115 | 0:bf7b9fba3924 | 71 | Select the signal type and observe AOUT signal by oscilloscope. |
frank26080115 | 0:bf7b9fba3924 | 72 | Press ESC if you want to terminate trasmitting the currect signal type |
frank26080115 | 0:bf7b9fba3924 | 73 | and generate other signal types. |
frank26080115 | 0:bf7b9fba3924 | 74 | |
frank26080115 | 0:bf7b9fba3924 | 75 | @Directory contents: |
frank26080115 | 0:bf7b9fba3924 | 76 | \EWARM: includes EWARM (IAR) project and configuration files |
frank26080115 | 0:bf7b9fba3924 | 77 | \Keil: includes RVMDK (Keil)project and configuration files |
frank26080115 | 0:bf7b9fba3924 | 78 | |
frank26080115 | 0:bf7b9fba3924 | 79 | lpc17xx_libcfg.h: Library configuration file - include needed driver library for this example |
frank26080115 | 0:bf7b9fba3924 | 80 | makefile: Example's makefile (to build with GNU toolchain) |
frank26080115 | 0:bf7b9fba3924 | 81 | dac_wave_generate.c: Main program |
frank26080115 | 0:bf7b9fba3924 | 82 | |
frank26080115 | 0:bf7b9fba3924 | 83 | @How to run: |
frank26080115 | 0:bf7b9fba3924 | 84 | Hardware configuration: |
frank26080115 | 0:bf7b9fba3924 | 85 | This example was tested on: |
frank26080115 | 0:bf7b9fba3924 | 86 | Keil MCB1700 with LPC1768 vers.1 |
frank26080115 | 0:bf7b9fba3924 | 87 | These jumpers must be configured as following: |
frank26080115 | 0:bf7b9fba3924 | 88 | - VDDIO: ON |
frank26080115 | 0:bf7b9fba3924 | 89 | - VDDREGS: ON |
frank26080115 | 0:bf7b9fba3924 | 90 | - VBUS: ON |
frank26080115 | 0:bf7b9fba3924 | 91 | - SPK: OFF |
frank26080115 | 0:bf7b9fba3924 | 92 | - Remain jumpers: OFF |
frank26080115 | 0:bf7b9fba3924 | 93 | IAR LPC1768 KickStart vers.A |
frank26080115 | 0:bf7b9fba3924 | 94 | These jumpers must be configured as following: |
frank26080115 | 0:bf7b9fba3924 | 95 | - PWR_SEL: depend on power source |
frank26080115 | 0:bf7b9fba3924 | 96 | - DBG_EN : ON |
frank26080115 | 0:bf7b9fba3924 | 97 | - Remain jumpers: OFF |
frank26080115 | 0:bf7b9fba3924 | 98 | |
frank26080115 | 0:bf7b9fba3924 | 99 | Serial display configuration: (e.g: TeraTerm, Hyperterminal, Flash Magic...) |
frank26080115 | 0:bf7b9fba3924 | 100 | 115200bps |
frank26080115 | 0:bf7b9fba3924 | 101 | 8 data bit |
frank26080115 | 0:bf7b9fba3924 | 102 | No parity |
frank26080115 | 0:bf7b9fba3924 | 103 | 1 stop bit |
frank26080115 | 0:bf7b9fba3924 | 104 | No flow control |
frank26080115 | 0:bf7b9fba3924 | 105 | |
frank26080115 | 0:bf7b9fba3924 | 106 | Running mode: |
frank26080115 | 0:bf7b9fba3924 | 107 | This example can run on RAM/ROM mode. |
frank26080115 | 0:bf7b9fba3924 | 108 | |
frank26080115 | 0:bf7b9fba3924 | 109 | Note: If want to burn hex file to board by using Flash Magic, these jumpers need |
frank26080115 | 0:bf7b9fba3924 | 110 | to be connected: |
frank26080115 | 0:bf7b9fba3924 | 111 | - MCB1700 with LPC1768 ver.1: |
frank26080115 | 0:bf7b9fba3924 | 112 | + RST: ON |
frank26080115 | 0:bf7b9fba3924 | 113 | + ISP: ON |
frank26080115 | 0:bf7b9fba3924 | 114 | - IAR LPC1768 KickStart vers.A: |
frank26080115 | 0:bf7b9fba3924 | 115 | + RST_E: ON |
frank26080115 | 0:bf7b9fba3924 | 116 | + ISP_E: ON |
frank26080115 | 0:bf7b9fba3924 | 117 | |
frank26080115 | 0:bf7b9fba3924 | 118 | (Please reference "LPC1000 Software Development Toolchain" - chapter 4 "Creating and working with |
frank26080115 | 0:bf7b9fba3924 | 119 | LPC1000CMSIS project" for more information) |
frank26080115 | 0:bf7b9fba3924 | 120 | |
frank26080115 | 0:bf7b9fba3924 | 121 | Step to run: |
frank26080115 | 0:bf7b9fba3924 | 122 | - Step 1: Build example. |
frank26080115 | 0:bf7b9fba3924 | 123 | - Step 2: Burn hex file into board (if run on ROM mode) |
frank26080115 | 0:bf7b9fba3924 | 124 | - Step 3: Connect UART0 on this board to COM port on your computer |
frank26080115 | 0:bf7b9fba3924 | 125 | - Step 4: Configure hardware and serial display as above instruction |
frank26080115 | 0:bf7b9fba3924 | 126 | - Step 5: Run example and observe AOUT signal by oscilloscope |
frank26080115 | 0:bf7b9fba3924 | 127 | |
frank26080115 | 0:bf7b9fba3924 | 128 | (Pls see "LPC17xx Example Description" document - chapter "Examples > DAC > WaveGenerate" |
frank26080115 | 0:bf7b9fba3924 | 129 | for more details) |
frank26080115 | 0:bf7b9fba3924 | 130 | @Tip: |
frank26080115 | 0:bf7b9fba3924 | 131 | - Open \EWARM\*.eww project file to run example on IAR |
frank26080115 | 0:bf7b9fba3924 | 132 | - Open \RVMDK\*.uvproj project file to run example on Keil |