微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > stm32 低功耗设计[操作寄存器+库函数]

stm32 低功耗设计[操作寄存器+库函数]

时间:11-25 来源:互联网 点击:
  • 125

    126//RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);

    127

    128RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);

    129//RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR|RCC_APB1Periph_BKP|RCC_APB1Periph_WWDG, ENABLE);

    130

    131}

    132

    133

    134voidUSART_Configuration(void)

    135{

    136USART_InitTypeDef USART_InitStructure;

    137USART_ClockInitTypeDef USART_ClockInitStructure;

    138

    139USART_ClockInitStructure.USART_Clock = USART_Clock_Disable;

    140USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low;

    141USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge;

    142USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable;

    143USART_ClockInit(USART1 , &USART_ClockInitStructure);

    144

    145USART_InitStructure.USART_BaudRate = 9600;

    146USART_InitStructure.USART_WordLength = USART_WordLength_8b;

    147USART_InitStructure.USART_StopBits = USART_StopBits_1;

    148USART_InitStructure.USART_Parity = USART_Parity_No;

    149USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

    150USART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx;

    151USART_Init(USART1,&USART_InitStructure);

    152

    153USART_Cmd(USART1,ENABLE);

    154}

    155

    156voidEXTI_Configuration(void)

    157{

    158EXTI_InitTypeDef EXTI_InitStructure;

    159

    160EXTI_InitStructure.EXTI_Line = EXTI_Line0;

    161EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

    162EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

    163EXTI_InitStructure.EXTI_LineCmd = ENABLE;

    164

    165EXTI_Init(&EXTI_InitStructure);

    166

    167}

    168

    169voidNVIC_Configuration(void)

    170{

    171NVIC_InitTypeDef NVIC_InitStructure;

    172

    173NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

    174

    175NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;

    176NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

    177NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

    178NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    179NVIC_Init(&NVIC_InitStructure);

    180}

    181

    182#if PRINTF_ON

    183

    184intfputc(intch,FILE*f)

    185{

    186USART_SendData(USART1,(u8) ch);

    187while(USART_GetFlagStatus(USART1,USART_FLAG_TC) == RESET);

    188returnch;

    189}

    190

    191#endif

    stm32f10x_it.c

    view source

    print?

    01#include "stm32f10x_it.h"

    02

    03#include "stdio.h"

    04

    05

    06voidEXTI0_IRQHandler(void)

    07{

    08GPIO_WriteBit(GPIOA,GPIO_Pin_7,Bit_SET);

    09

    10//EXTI_ClearFlag(EXTI_Line0); //清除此中断标志位,系统由于唤醒将直接复位

    11

    12}

    13

    14voidSysTick_Handler(void)

    15{

    16GPIO_WriteBit(GPIOA,GPIO_Pin_4,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOA,GPIO_Pin_4)));

    17}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top