📄 setup.lst
字号:
###############################################################################
# #
# 10/Jun/2008 15:10:58 #
# IAR ARM ANSI C/C++ Compiler V5.11.0.20622/W32 EVALUATION #
# Copyright 1999-2007 IAR Systems. All rights reserved. #
# #
# Cpu mode = thumb #
# Endian = little #
# Source file = E:\ELE\yten\pro\Setup.c #
# Command line = E:\ELE\yten\pro\Setup.c -lcN #
# E:\ELE\yten\pro\Debug\List\ -o #
# E:\ELE\yten\pro\Debug\Obj\ --debug --endian little #
# --cpu Cortex-M3 -e --fpu None --dlib_config #
# D:\IARARM\ARM\INC\DLib_Config_Normal.h -I #
# E:\ELE\yten\pro\ -I E:\ELE\yten\pro\..\LIBRARY\INC\ -I #
# D:\IARARM\ARM\INC\ -Oh #
# List file = E:\ELE\yten\pro\Debug\List\Setup.lst #
# Object file = E:\ELE\yten\pro\Debug\Obj\Setup.o #
# #
# #
###############################################################################
E:\ELE\yten\pro\Setup.c
1 /******************************************************************************/
2 /* SETUP.C: Setup Functions */
3 /******************************************************************************/
4 /* This file is part of the uVision/ARM development tools. */
5 /* Copyright (c) 2005-2007 Keil Software. All rights reserved. */
6 /* This software may only be used under the terms of a valid, current, */
7 /* end user licence from KEIL for a compatible version of KEIL software */
8 /* development tools. Nothing else gives you the right to use this software. */
9 /******************************************************************************/
10
11 #include <stm32f10x_lib.h> /* STM32F10x Library Definitions */
12
13
14 #define ADC1_DR_Address ((u32)0x4001244C)
15
16 unsigned short int ADC_ConvertedValue;
17
18 GPIO_InitTypeDef GPIO_InitStructure;
19 USART_InitTypeDef USART_InitStructure;
20 ADC_InitTypeDef ADC_InitStructure;
21 DMA_InitTypeDef DMA_InitStructure;
22
23
24 void SetupClock (void)
25 {
26 RCC_DeInit (); /* RCC system reset(for debug purpose)*/
27 RCC_HSEConfig (RCC_HSE_ON); /* Enable HSE */
28
29 /* Wait till HSE is ready */
30 while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET);
31
32 RCC_HCLKConfig (RCC_SYSCLK_Div1); /* HCLK = SYSCLK */
33 RCC_PCLK2Config (RCC_HCLK_Div1); /* PCLK2 = HCLK */
34 RCC_PCLK1Config (RCC_HCLK_Div2); /* PCLK1 = HCLK/2 */
35 RCC_ADCCLKConfig (RCC_PCLK2_Div4); /* ADCCLK = PCLK2/4 */
36
37 *(vu32 *)0x40022000 = 0x01; /* Flash 2 wait state */
38
39 /* PLLCLK = 8MHz * 9 = 72 MHz */
40 RCC_PLLConfig (RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
41
42 RCC_PLLCmd (ENABLE); /* Enable PLL */
43
44 /* Wait till PLL is ready */
45 while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
46
47 /* Select PLL as system clock source */
48 RCC_SYSCLKConfig (RCC_SYSCLKSource_PLLCLK);
49
50 /* Wait till PLL is used as system clock source */
51 while (RCC_GetSYSCLKSource() != 0x08);
52
53 /* Enable USART1 and GPIOA clock */
54 RCC_APB2PeriphClockCmd (RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
55
56 /* SysTick event each 10 ms with input clock equal to 9MHz (HCLK/8) */
57 SysTick_SetReload(90000);
58
59 SysTick_ITConfig(ENABLE); /* Enable SysTick interrupt */
60 }
61
62
63 void SetupADC (void) {
64
65 /* Enable GPIOA clock */
66 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
67
68 /* Enable DMA clock */
69 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA, ENABLE);
70
71 /* Enable ADC1 clock */
72 RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
73
74 /* Configure PA1 (ADC Channel1) as analog input */
75 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
76 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
77 GPIO_Init(GPIOA, &GPIO_InitStructure);
78
79 /* DMA Channel1 Configuration ----------------------------------------------*/
80 DMA_DeInit(DMA_Channel1);
81 DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
82 DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValue;
83 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
84 DMA_InitStructure.DMA_BufferSize = 1;
85 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
86 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
87 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
88 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
89 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
90 DMA_InitStructure.DMA_Priority = DMA_Priority_High;
91 DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
92 DMA_Init(DMA_Channel1, &DMA_InitStructure);
93
94 DMA_Cmd(DMA_Channel1, ENABLE); /* Enable DMA Channel1 */
95
96 /* ADC1 Configuration (ADC1CLK = 18 MHz) -----------------------------------*/
97 ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
98 ADC_InitStructure.ADC_ScanConvMode = ENABLE;
99 ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
100 ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
101 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
102 ADC_InitStructure.ADC_NbrOfChannel = 1;
103 ADC_Init(ADC1, &ADC_InitStructure);
104
105 /* ADC1 Regular Channel1 Configuration */
106 ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_55Cycles5);
107
108 ADC_DMACmd(ADC1, ENABLE); /* Enable ADC1's DMA interface */
109 ADC_Cmd (ADC1, ENABLE); /* Enable ADC1 */
110 ADC_SoftwareStartConvCmd(ADC1,ENABLE);/* Start ADC1 Software Conversion */
111 }
112
113
114 void SetupLED (void) {
115
116 /* Enable GPIOB clock */
117 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
118
119 /* Configure PB8..PB15 as outputs push-pull, max speed 50 MHz */
120 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |
121 GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 |
122 GPIO_Pin_14 | GPIO_Pin_15 ;
123 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
124 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
125 GPIO_Init(GPIOB, &GPIO_InitStructure);
126
127 /* Enable the SysTick Counter */
128 SysTick_CounterCmd(SysTick_Counter_Enable);
129 }
Maximum stack usage in bytes:
Function .cstack
-------- -------
SetupADC 24
SetupClock 8
SetupLED 8
Section sizes:
Function/Label Bytes
-------------- -----
ADC_InitStructure 70
USART_InitStructure 24
SetupClock 136
SetupADC 192
SetupLED 48
??DataTable1 4
94 bytes in section .bss
380 bytes in section .text
380 bytes of CODE memory
94 bytes of DATA memory
Errors: none
Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -