嵌入式系统课程设计(温度检测报警系统)(2)

2019-04-21 15:51

三、程序流程图 对应警告灯亮 是 判断当前温度 是否超过设定范围 开始 各模块初始化 设定温度 显示当前 时间温度 计时一秒

否 警告灯全灭 5

四、软件设计

用到的库文件:

stm32f10x_adc.h,stm32f10x_dma.h,stm32f10x_flash.h,stm32f10x_gpio.h,stm32f10x_rcc.h,stm32f10x_usart.h,misc.h 自己编写的文件:

main.c,stm32f10x_it.c,stm32f10x_it.h

main文件:

#include \#include \#include \

#define ADC1_DR_Address ((uint32_t)0x4001244C) extern __IO u16 ADC_ConvertedValue; extern __IO u16 calculated_temp; __IO u16 Current_Temp;

unsigned char sec=0,min=0,hour=0; typedef struct {

int tm_sec; int tm_min; int tm_hour; }rtc_time;

rtc_time systmtime;

__IO u16 upper_bound;

6

__IO u16 lower_bound;

//static uint8_t USART_Scanf(uint32_t value); void Time_Regulate(rtc_time *tm);

unsigned int TimingDelay=0; unsigned int KEY_ON; unsigned int KEY_OFF; void Delay(u32 count) { }

void LED_GPIO_Config() {

GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE); // GPIO_InitStructure.GPIO_Pin

=

u32 i=0;

for(;i

使能PD端口时钟

GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11; //LED0-->PD.8端口配置 }

void SysTick_Init() {

if (SysTick_Config(SystemCoreClock / 1000))

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO 速度 GPIO_Init(GPIOD, &GPIO_InitStructure); //根据设定参数初始化 输出 50MHz GPIOB.5

7

}

{ }

SysTick->CTRL &= ~ SysTick_CTRL_ENABLE_Msk;//关闭滴答定时器 //SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;//开启滴答定时器

while(1);

void Delay_ms(__IO u32 nTime) { }

void RCC_Config(void)//配置时钟 { }

void GPIO_Config(void) {

GPIO_InitTypeDef GPIO_InitStructure; /***Config PA.01 (ADC1)***/

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOC, &GPIO_InitStructure);

/***Config LED ***/

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);//DMA RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1

| |

TimingDelay=nTime;

SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;//打开 while(TimingDelay != 0);

RCC_APB2Periph_GPIOC, ENABLE);//ADC1 and GPIOC RCC_APB2Periph_GPIOA, ENABLE);//USART

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE); // 使能PD端口时钟 LED

8

}

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO 速度 GPIO_Init(GPIOD, &GPIO_InitStructure); //根据设定参数初始化

/***Config USART ***/

/* Configure USART1 Tx (PA.09) as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure);

/* Configure USART1 Rx (PA.10) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure);

输出 50MHz GPIOB.5

void DMA_Config(void) {

/* DMA channel1 configuration */ DMA_InitTypeDef DMA_InitStructure; DMA_DeInit(DMA1_Channel1);

DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address; DMA_InitStructure.DMA_MemoryBaseAddr

DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 16;

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

= =

/*ADC??*/

(u32)&ADC_ConvertedValue;

9


嵌入式系统课程设计(温度检测报警系统)(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:已加 计算机硬件维护工程师试题和答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: