您的当前位置:首页正文

STM32内部AD采样程序--运行通过(测量电压范围0~33V)(运行通过的ARM

来源:我们爱旅游
STM32内部AD采样程序--运行通过(测量电压范围0~33V)(运行通过的ARM.txt*一篇一篇的翻着以前的的签名,那时候的签名有多幼稚就有多么的幼稚。你连让我报复的资格都没有-〞好想某天来电显示是你的号码。好想某天你的状态是为我而写。 有些人,我们明知道是爱的,也要去放弃,因为没结局 /******************************************************************************* * File Name : main.c

* Author : Wuhan R&D Center, Embest * Date First Issued : 08/08/2008

* Description : Main program body

********************************************************************************/

/* Includes ------------------------------------------------------------------*/ #include \"stm32f10x_lib.h\" #include\"stdio.h\"

/* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ //#define ADC1_DR_Address ((u32)0x4001244C) float AD_value=0.0;

u8 adc_1[6]={0};//用来存放经ADC转换后的电压值的每一位数值。

/* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ ADC_InitTypeDef ADC_InitStructure; //DMA_InitTypeDef DMA_InitStructure; //vu16 ADC_ConvertedValue; ErrorStatus HSEStartUpStatus;

/* Private function prototypes -----------------------------------------------*/ void RCC_Configuration(void); void GPIO_Configuration(void);

void SysTick_Configuration(void);

#define LED1ON GPIO_SetBits(GPIOF,GPIO_Pin_0)

#define LED1OFF GPIO_ResetBits(GPIOF,GPIO_Pin_0) //片选cs

#define LED2ON GPIO_SetBits(GPIOF,GPIO_Pin_1)

#define LED2OFF GPIO_ResetBits(GPIOF,GPIO_Pin_1)//复位rest

#define LED3ON GPIO_SetBits(GPIOF,GPIO_Pin_2)

#define LED3OFF GPIO_ResetBits(GPIOF,GPIO_Pin_2)//数据sdata #define LED4ON GPIO_SetBits(GPIOF,GPIO_Pin_3)

#define LED4OFF GPIO_ResetBits(GPIOF,GPIO_Pin_3)//时钟sclk

unsigned char Ver='A'; //驱动版本,默认为A版本,一共4个版本

unsigned char zifu[]={ /*-- 文字: --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*-- 文字: ! --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00,

/*-- 文字: \" --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x28,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*-- 文字: # --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x28,0x28,0xFC,0x28,0x50,0xFC,0x50,0x50,0x00,0x00,

/*-- 文字: $ --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x20,0x78,0xA8,0xA0,0x60,0x30,0x28,0xA8,0xF0,0x20,0x00,

/*-- 文字: % --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x48,0xA8,0xB0,0x50,0x28,0x34,0x54,0x48,0x00,0x00,

/*-- 文字: & --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x20,0x50,0x50,0x78,0xA8,0xA8,0x90,0x6C,0x00,0x00,

/*-- 文字: ' --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*-- 文字: ( --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x04,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x04,0x00,

/*-- 文字: ) --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x40,0x00,

/*-- 文字: * --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x20,0xA8,0x70,0x70,0xA8,0x20,0x00,0x00,0x00,

/*-- 文字: + --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x20,0x20,0x20,0xF8,0x20,0x20,0x20,0x00,0x00,0x00,

/*-- 文字: , --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80,

/*-- 文字: - --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,

/*-- 文字: . --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,

/*-- 文字: / --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x08,0x10,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x80,0x00,

/*-- 文字: 0 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00,

/*-- 文字: 1 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,

/*-- 文字: 2 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x40,0x80,0xF8,0x00,0x00,

/*-- 文字: 3 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,0x00,0x00,

/*-- 文字: 4 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x10,0x30,0x50,0x50,0x90,0x78,0x10,0x18,0x00,0x00,

/*-- 文字: 5 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF8,0x80,0x80,0xF0,0x08,0x08,0x88,0x70,0x00,0x00,

/*-- 文字: 6 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x90,0x80,0xF0,0x88,0x88,0x88,0x70,0x00,0x00,

/*-- 文字: 7 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF8,0x90,0x10,0x20,0x20,0x20,0x20,0x20,0x00,0x00,

/*-- 文字: 8 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x88,0x70,0x00,0x00,

/*-- 文字: 9 --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x48,0x70,0x00,0x00,

/*-- 文字: : --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x20,0x00,0x00,

/*-- 文字: ; --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x20,0x00,

/*-- 文字: < --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00,

/*-- 文字: = --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,

/*-- 文字: > --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00,

/*-- 文字: ? --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x20,0x00,0x20,0x00,0x00,

/*-- 文字: @ --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x88,0x98,0xA8,0xA8,0xB8,0x80,0x78,0x00,0x00,

/*-- 文字: A --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/

/*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x20,0x20,0x30,0x50,0x50,0x78,0x48,0xCC,0x00,0x00,

/*-- 文字: B --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF0,0x48,0x48,0x70,0x48,0x48,0x48,0xF0,0x00,0x00,

/*-- 文字: C --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x78,0x88,0x80,0x80,0x80,0x80,0x88,0x70,0x00,0x00,

/*-- 文字: D --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF0,0x48,0x48,0x48,0x48,0x48,0x48,0xF0,0x00,0x00,

/*-- 文字: E --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x48,0xF8,0x00,0x00,

/*-- 文字: F --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x40,0xE0,0x00,0x00,

/*-- 文字: G --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x38,0x48,0x80,0x80,0x9C,0x88,0x48,0x30,0x00,0x00,

/*-- 文字: H --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xCC,0x48,0x48,0x78,0x48,0x48,0x48,0xCC,0x00,0x00,

/*-- 文字: I --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00,

/*-- 文字: J --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0xE0,0x00,

/*-- 文字: K --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xEC,0x48,0x50,0x60,0x50,0x50,0x48,0xEC,0x00,0x00,

/*-- 文字: L --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x44,0xFC,0x00,0x00,

/*-- 文字: M --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xD8,0xD8,0xD8,0xD8,0xA8,0xA8,0xA8,0xA8,0x00,0x00,

/*-- 文字: N --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xDC,0x48,0x68,0x68,0x58,0x58,0x48,0xE8,0x00,0x00,

/*-- 文字: O --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00,

/*-- 文字: P --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF0,0x48,0x48,0x70,0x40,0x40,0x40,0xE0,0x00,0x00,

/*-- 文字: Q --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x70,0x88,0x88,0x88,0x88,0xE8,0x98,0x70,0x18,0x00,

/*-- 文字: R --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF0,0x48,0x48,0x70,0x50,0x48,0x48,0xEC,0x00,0x00,

/*-- 文字: S --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x78,0x88,0x80,0x60,0x10,0x08,0x88,0xF0,0x00,0x00,

/*-- 文字: T --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF8,0xA8,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,

/*-- 文字: U --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xCC,0x48,0x48,0x48,0x48,0x48,0x48,0x30,0x00,0x00,

/*-- 文字: V --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xCC,0x48,0x48,0x50,0x50,0x30,0x20,0x20,0x00,0x00,

/*-- 文字: W --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xA8,0xA8,0xA8,0x70,0x50,0x50,0x50,0x50,0x00,0x00,

/*-- 文字: X --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xD8,0x50,0x50,0x20,0x20,0x50,0x50,0xD8,0x00,0x00,

/*-- 文字: Y --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xD8,0x50,0x50,0x20,0x20,0x20,0x20,0x70,0x00,0x00,

/*-- 文字: Z --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xF8,0x90,0x10,0x20,0x20,0x40,0x48,0xF8,0x00,0x00,

/*-- 文字: [ --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00,

/*-- 文字: \\ --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x00,0x00,

/*-- 文字: ] --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00,

/*-- 文字: ^ --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*-- 文字: _ --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,

/*-- 文字: ` --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*-- 文字: a --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x38,0x48,0x3C,0x00,0x00,

/*-- 文字: b --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0x70,0x00,0x00,

/*-- 文字: c --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x40,0x40,0x38,0x00,0x00,

/*-- 文字: d --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x18,0x08,0x08,0x38,0x48,0x48,0x48,0x3C,0x00,0x00,

/*-- 文字: e --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x78,0x40,0x38,0x00,0x00,

/*-- 文字: f --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x1C,0x20,0x20,0x78,0x20,0x20,0x20,0x78,0x00,0x00,

/*-- 文字: g --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x3C,0x48,0x30,0x40,0x78,0x44,0x38,

/*-- 文字: h --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0xEC,0x00,0x00,

/*-- 文字: i --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x70,0x00,0x00,

/*-- 文字: j --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x10,0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0xE0,

/*-- 文字: k --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xC0,0x40,0x40,0x5C,0x50,0x70,0x48,0xEC,0x00,0x00,

/*-- 文字: l --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00,

/*-- 文字: m --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/

/*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xF0,0xA8,0xA8,0xA8,0xA8,0x00,0x00,

/*-- 文字: n --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0xEC,0x00,0x00,

/*-- 文字: o --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x30,0x00,0x00,

/*-- 文字: p --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0x70,0x40,0xE0,

/*-- 文字: q --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x48,0x48,0x38,0x08,0x1C,

/*-- 文字: r --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xD8,0x60,0x40,0x40,0xE0,0x00,0x00,

/*-- 文字: s --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x78,0x40,0x30,0x08,0x78,0x00,0x00,

/*-- 文字: t --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00,

/*-- 文字: u --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xD8,0x48,0x48,0x48,0x3C,0x00,0x00,

/*-- 文字: v --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x00,0x00,

/*-- 文字: w --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xA8,0xA8,0x70,0x50,0x50,0x00,0x00,

/*-- 文字: x --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xD8,0x50,0x20,0x50,0xD8,0x00,0x00,

/*-- 文字: y --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x20,0xC0,

/*-- 文字: z --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x00,0x00,0x00,0x00,0x78,0x10,0x20,0x20,0x78,0x00,0x00,

/*-- 文字: { --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x18,0x10,0x10,0x10,0x20,0x10,0x10,0x10,0x10,0x18,0x00,

/*-- 文字: | --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,

/*-- 文字: } --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x00,0x60,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x60,0x00,

/*-- 文字: ~ --*/

/*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/

0x40,0xA4,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};

unsigned char hanzi[]={

/*---------------雨----------------*/

0x00,0x4F,0xFE,0x4,0x7,0xFC,0x66,0x45,0x54,0x44,0x46,0x64,0x55,0x44,0x44,0x45, 0xC0,0x00,

/*---------------亭----------------*/

0x04,0x07,0xFC,0x00,0x01,0xF8,0x10,0x8F,0xFE,0x80,0x23,0xF8,0x04,0x00,0x40,0x1C, 0x00,0x00,

/*---------------电----------------*/

0x04,0x00,0x44,0x7F,0xE4,0x44,0x7F,0xC4,0x44,0x44,0x47,0xFC,0x44,0x00,0x42,0x03, 0xE0,0x00,

/*---------------子----------------*/

0x7F,0xC0,0x08,0x01,0x00,0x60,0x04,0x4F,0xFE,0x04,0x00,0x40,0x04,0x00,0x40,0x1C, 0x00,0x00,

/*---------------我----------------*/

0x0A,0x8F,0x24,0x12,0x0F,0xFE,0x12,0x01,0x64,0x3A,0x8D,0x10,0x13,0x21,0xCA,0x70, 0x60,0x00,

/*---------------是----------------*/

0x1F,0x81,0x08,0x1F,0x81,0x08,0x1F,0x80,0x00,0xFF,0xE2,0x40,0x37,0xC4,0xC0,0x87, 0xE0,0x00,

/*---------------企----------------*/

0x04,0x00,0x60,0x09,0x01,0x08,0x24,0x6C,0x40,0x17,0x81,0x40,0x14,0x01,0x40,0xFF, 0xE0,0x00,

/*---------------鹅----------------*/

0x30,0x8D,0xBC,0x52,0x4F,0xB4,0x52,0xC7,0x60,0xDB,0xE5,0x02,0x6B,0xE4,0xA2,0xC6, 0xC0,0x00,

/*---------------我----------------*/

0x0A,0x8F,0x24,0x12,0x0F,0xFE,0x12,0x01,0x64,0x3A,0x8D,0x10,0x13,0x21,0xCA,0x70, 0x60,0x00,

/*---------------怕----------------*/

0x21,0x02,0x20,0x27,0xEB,0x42,0xAC,0x2A,0x42,0x27,0xE2,0x42,0x24,0x22,0x42,0x27, 0xE0,0x00,

/*---------------谁----------------*/

0x45,0x02,0x48,0x0F,0xE0,0xC8,0xD7,0xE4,0x48,0x44,0x84,0x7E,0x54,0x86,0x7E,0x04, 0x00,0x00,

/*-------------------------------*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00, };

void delayms(unsigned int ii)//1ms延时函数

{

unsigned int i,x; for (x=0;xfor (i=0;i<100;i++); } }

void send(unsigned char value, unsigned char cd) //写8位数据 {

unsigned char i,dt; LED1OFF; LED4OFF; if(cd == 0) LED3OFF; else LED3ON; LED4ON;

dt=value;

for(i=0;i<8;i++) {

LED4OFF; if(dt&0x80) LED3ON; else

LED3OFF; dt=dt<<1; LED4ON; }

LED1ON;//cs=1; }

void readdata() //读数据 {

unsigned char i,j; unsigned char ch[6];

send(0x09, 0); // 读数据 LED1OFF;//cs=0; LED4OFF;//sclk=0; for (i=0;i<6;i++) {

ch[i]=0;

for (j=0;j<8;j++)

{

LED4ON;//sclk=1;

if (!(GPIO_ReadOutputDataBit(GPIOF,GPIO_Pin_2)))//sdata==0) {

ch[i]=ch[i]|(1<<(7-j)); }

LED4OFF;//sclk=0; } }

switch(ch[0]) {

case 255: Ver='A'; break; case 127: Ver='B'; break; case 0:

if(ch[1]+ch[2]+ch[3]==0) {

Ver='D'; }else {

Ver='C'; }

break; }

LED1ON;//cs=1; }

void LCD_Initialize() //LCD初始化 {

unsigned char i; LED2ON;//rest=1; LED1ON;//cs=1; LED3OFF;//sdata=0; LED4ON;//sclk=1; LED2OFF;//rest=0; delayms(50); LED2ON;//rest=1; delayms(50);

send(0x00, 0); // NOP delayms(5);

send(0x01, 0); // LCD Software Reset delayms(5);

send(0xC6, 0); // Initial Escape

send(0xB9, 0); // Refresh set send(0x00, 1);

readdata(); //读出数据

send(0xB5, 0); // Gamma Curve Set send(0x01, 1);

send(0xbd, 0); //common driver output select//很重要的 if(Ver=='D') {

send(0x04, 1); }else {

send(0x00, 1); }

send(0xBE, 0); // Power Control send(0x03, 1);

send(0x11, 0); // Sleep out

send(0xBA, 0); // Power Control send(0x7F, 1); send(0x03, 1);

send(0x36, 0); // 扫描方式 if (Ver=='A') {

send(0x00|0x08,1); //RGB }

else {

send(0x00,1); //RGB }

send(0xB7, 0); // Temperature gradient set for(i=0; i<14; i++) {

send(0, 1); }

send(0x29, 0); //display ON

send(0x03, 0); // Booster Voltage ON

delayms(20); // Booster Voltage stabilisieren lassen

send(0x20, 0); //display inversion OFF

send(0x25, 0); // Write contrast

switch(Ver) //对比度设置 {

case 'A':

send(70, 1); //对比度设置 break; case 'B':

send(67, 1); //对比度设置 break; case 'C':

//send(74, 1); send(66, 1);

// send(64, 1); //对比度设置 break;

case 'D': //对比度设置 send(39, 1); break; } }

//************************

//颜色模式设置:color=1为4096色模式 // :color=0为256色模式 //************************

void LCD_ColorSet(unsigned char Color) {

if (Color==1) {

send(0x3a, 0); //interface pixel format

send(0x03, 1); //0x03 为4096色,0x02为256色 } else {

send(0x3a, 0); //interface pixel format

send(0x02, 1); //0x03 为4096色,0x02为256色

send(0x2d, 0); //调色板设置 if (Ver=='B'||Ver=='C') {

//red

send(~0x00, 1); send(~0x02, 1); send(~0x03, 1); send(~0x04, 1); send(~0x05, 1); send(~0x06, 1); send(~0x08, 1); send(~0x0f, 1);

//green

send(~0x00, 1); send(~0x02, 1); send(~0x03, 1); send(~0x04, 1); send(~0x05, 1); send(~0x06, 1); send(~0x08, 1); send(~0x0f, 1); //blue

send(~0x00, 1); send(~0x03, 1); send(~0x06, 1); send(~0x0f, 1); }else {

//red

send(0x00, 1);

send(0x02, 1); send(0x03, 1); send(0x04, 1); send(0x05, 1); send(0x06, 1); send(0x08, 1); send(0x0f, 1);

//green

send(0x00, 1); send(0x02, 1); send(0x03, 1); send(0x04, 1); send(0x05, 1); send(0x06, 1); send(0x08, 1); send(0x0f, 1); //blue

send(0x00, 1); send(0x03, 1); send(0x06, 1); send(0x0f, 1); } } } void addset(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2) //坐标设置 4个参数依次为开始X,开始Y,结束x,结束Y {

send(0x2a,0 );//column address set send(x1,1 ); send(x2,1 );

send(0x2B,0 );//page address set send(y1,1 ); send(y2,1 );

send(0x2C,0 );//memory write }

//************************

//清屏:color=1为4096色模式清屏 // :color=0为256色模式清屏 //************************

void LCD_Clear(unsigned int value,unsigned char Color) {

unsigned char x, y; addset(0,0,97,66); if (Color==1) {

for(y = 0; y < 67; y ++) {

for(x = 0; x < 49;x ++) { send(value>>4,1);

send(((value&0x0f)<<4)|(value>>8),1); send(value,1); } } } else {

for(y = 0; y < 67; y ++) {

for(x = 0; x < 98; x ++) {

send(value,1); } } } }

//在指定位置显示一个字符(8*12大小) //dcolor为内容颜色,gbcolor为背静颜色

void showzifu(unsigned char x,unsigned char y,unsigned char value,unsigned char dcolor,unsigned char bgcolor) {

unsigned char i,j;

unsigned char *temp=zifu;

addset(x,y,x+7,y+11); //设置区域 temp+=(value-32)*12; for(j=0;j<12;j++) {

for(i=0;i<8;i++) {

if((*temp&(1<<(7-i)))!=0) {

send(dcolor,1); } else {

send(bgcolor,1);

} }

temp++; } }

//在指定位置显示一个字符串(8*12大小) //dcolor为内容颜色,gbcolor为背静颜色

void showzifustr(unsigned char x,unsigned char y,unsigned char *str,unsigned char dcolor,unsigned char bgcolor) {

unsigned char x1,y1; x1=x; y1=y;

while(*str!='\\0') {

showzifu(x1,y1,*str,dcolor,bgcolor); x1+=7; str++; }

}//在指定位置显示一个汉字(12*12大小) //dcolor为内容颜色,gbcolor为背静颜色

void showhanzi(unsigned char x,unsigned char y,unsigned char value,unsigned char dcolor,unsigned char bgcolor) {

unsigned char i,j;

unsigned char *temp=hanzi;

addset(x,y,x+11,y+11); //设置区域 temp+=value*18; for(j=0;j<18;j++) {

for(i=0;i<8;i++) {

if((*temp&(1<<(7-i)))!=0) {

send(dcolor,1); } else {

send(bgcolor,1); } }

temp++;

} }

void showdian(unsigned char x,unsigned char y,unsigned char dcolor,unsigned char bgcolor) {

addset(x,y,x+1,y+1); //设置区域

send(dcolor,1);

send(bgcolor,1); }

void delay_1ms(unsigned int ii)//1ms延时函数 {

unsigned int i,x; for (x=0;xfor (i=0;i<12000;i++);

//当i=12000时,就实现了1ms的延时。 //不过这个延时并不是非常精确的。 } }

int main(void) {

//int i,j; #ifdef DEBUG debug(); #endif

/* System clocks configuration ---------------------------------------------*/ RCC_Configuration(); SysTick_Configuration();

/* GPIO configuration ------------------------------------------------------*/

GPIO_Configuration();

//printf(\"\\r\\n USART1 print AD_value -------------------------- \\r\\n\");

/* DMA channel1 configuration ----------------------------------------------*/ /*DMA_DeInit(DMA1_Channel1);

DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;

DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValue; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 1;

DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;

DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel1, &DMA_InitStructure);

// Enable DMA channel1

DMA_Cmd(DMA1_Channel1, ENABLE); */

/* ADC1 configuration ------------------------------------------------------*/

ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;//ADC1和ADC2工作在独立模式。 ADC_InitStructure.ADC_ScanConvMode = ENABLE;//规定了模数转换工作在扫描模式(多通道)还是单次(单通道)模式。

ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;//模数转换是连续还是单次模式。 ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;//定义使用外部触发来启动规则通道的模数转换。这里none代表转换由软件而不是外部触发启动。 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;//ADC数据右对齐。

ADC_InitStructure.ADC_NbrOfChannel = 1;//规定了顺序进行规则转换的ADC通道数目。其取值范围为(1~16)。

ADC_Init(ADC1, &ADC_InitStructure);

/*为了能够正确地配置每一个ADC通道,用户在调用ADC_Init()之后,*/

/*必须调用ADC_ChannelConfig()来配置每个所使用通道的转换次序和采样时间。*/ /* ADC1 regular channel 13 configuration as 1th converted channel with an 239 cycles sample time*/

ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 1, ADC_SampleTime_55Cycles5);

/*上面的函数原形是:*/

/*void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, u8 ADC_Channel, u8 Rank, u8 ADC_SampleTime);*/

/* Enable ADC1 DMA */

// ADC_DMACmd(ADC1, ENABLE);

/* Enable ADC1 */

ADC_Cmd(ADC1, ENABLE);

/* Enable ADC1 reset calibaration register */ ADC_ResetCalibration(ADC1);

/* Check the end of ADC1 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC1));

/* Start ADC1 calibaration */ ADC_StartCalibration(ADC1);

/* Check the end of ADC1 calibration */ while(ADC_GetCalibrationStatus(ADC1));

/* Start ADC1 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE);//使能或者失能指定的ADC的软件转换启动功能.

LCD_Initialize() ;

LCD_ColorSet(0); //0为256色模式,1为4096色模式 LCD_Clear(255,0); //清屏

addset(0,0,103,81); //设置起止坐标,4个参数依次为开始X,开始Y,结束x,结束Y

while(1) {

//AD_value=(float)(ADC_GetConversionValue(ADC1))/0xfff*3.3; AD_value=((float)ADC_GetConversionValue(ADC1)/4095.0)*3.3; sprintf(adc_1,\"%.4f\ showzifustr(0,12,adc_1,0x03,255); showzifustr(64,12,\"V\ delay_1ms(10); }

/*{

for(i=0;i<100;i++) {for(j=0;j<20;j++) {

AD_value=ADC_GetConversionValue(ADC1);

// Printf message with AD value to serial port every 1 second showdian(i,65-AD_value/63 ,0x03,255); delayms(100); } }

LCD_Clear(255,0); //清屏 addset(0,0,103,81); }*/ }

/******************************************************************************* * Function Name : RCC_Configuration

* Description : Configures the different system clocks. * Input : None * Output : None * Return : None

*******************************************************************************/ void RCC_Configuration(void)

{ /* RCC system reset(for debug purpose) */ RCC_DeInit();

/* Enable HSE */

RCC_HSEConfig(RCC_HSE_ON);

/* Wait till HSE is ready */

HSEStartUpStatus = RCC_WaitForHSEStartUp();

if(HSEStartUpStatus == SUCCESS) {

/* HCLK = SYSCLK */

RCC_HCLKConfig(RCC_SYSCLK_Div1);

/* PCLK2 = HCLK */

RCC_PCLK2Config(RCC_HCLK_Div1);

/* PCLK1 = HCLK/2 */

RCC_PCLK1Config(RCC_HCLK_Div2);

/* ADCCLK = PCLK2/4 */

RCC_ADCCLKConfig(RCC_PCLK2_Div8);

/* Flash 2 wait state */

FLASH_SetLatency(FLASH_Latency_2); /* Enable Prefetch Buffer */

FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

/* PLLCLK = 8MHz * 9 = 56 MHz */

RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

/* Enable PLL */ RCC_PLLCmd(ENABLE);

/* Wait till PLL is ready */

while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { }

/* Select PLL as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

/* Wait till PLL is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x08) { } }

/* Enable peripheral clocks --------------------------------------------------*/ /* Enable DMA clock */

//RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);

/* Enable ADC1 and GPIOC clock */

RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_GPIOC, ENABLE);

/* Enable USART1 and GPIOA clock */

//RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOA| RCC_APB2Periph_GPIOC| RCC_APB2Periph_AFIO, ENABLE); }

void SysTick_Configuration(void) {

/* Select AHB clock(HCLK) as SysTick clock source */

SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

/* Set SysTick Priority to 3 */

NVIC_SystemHandlerPriorityConfig(SystemHandler_SysTick, 3, 0);

/* SysTick interrupt each 1ms with HCLK equal to 72MHz */ SysTick_SetReload(72000);

/* Enable the SysTick Interrupt */ SysTick_ITConfig(ENABLE); }

/******************************************************************************* * Function Name : GPIO_Configuration

* Description : Configures the different GPIO ports. * Input : None * Output : None * Return : None

*******************************************************************************/ void GPIO_Configuration(void) {

GPIO_InitTypeDef GPIO_InitStructure;

/* Configure PC.03 (ADC Channel13) as analog input -------------------------*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOC, &GPIO_InitStructure);

// Configure PF. as Output push-pull

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOF, &GPIO_InitStructure); }

#ifdef DEBUG

/******************************************************************************* * Function Name : assert_failed

* Description : Reports the name of the source file and the source line number * where the assert error has occurred. * Input : - file: pointer to the source file name * - line: assert error line source number * Output : None

* Return : None

*******************************************************************************/ void assert_failed(u8* file, u32 line) {

/* User can add his own implementation to report the file name and line number, ex: printf(\"Wrong parameters value: file %s on line %d\\r\\n\

/* Infinite loop */ while (1) { } }

#endif

/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

因篇幅问题不能全部显示,请点此查看更多更全内容