共10条
1/1 1 跳转至页
mxp20120501 ARM DIY进程贴


3楼
今天上午跑去电子市场,买齐了电阻、电容、排针啊神马的,下午焊接板子,现在看着自己焊接好的板子,爽啊!!哈哈……
STM32芯片图

板子正面图

板子背面图

STM32芯片图
板子正面图
板子背面图


5楼
按键中断控制LEDS流水灯
/******************************
文件:main.c
作者:mxp20120501
******************************/
#include "stm32f10x_lib.h"
void RCC_Configuration(void);
void GPIO_Configuration(void);
void NVIC_Configuration(void);
void EXTI_Configuration(void);
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
NVIC_Configuration();
EXTI_Configuration();
GPIO_RestBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
while(1);
}
void RCC_Configuration(void)
{
ErrorStatus HSEStartUpStatus;
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON); // 开启外部高速晶振
HSEStartUpStatus = RCC_WaitForHSEStartUp(); // 等待晶振起振
if(HSEStartUpStatus == SUCCESS)
{
FLASH_SetLatency(FLASH_Latency_2); // 2个等待周期
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); // 使能FLASH预取缓冲
RCC_HCLKConfig(RCC_SYSCLK_Div1); RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_PCLK2Config(RCC_HCLK_Div1);
RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_9);
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while(RCC_GetSYSCLKSource() != 0x08);
}
RCC_APB2PeriphClockCmdRCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOE,ENABLE);
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
// 设置 PE.2 PE.3 PE.4 PE.5 为推挽输出,最大翻转频率2MHz
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOE,&GPIO_InitStructure);
// 设置PA.0浮空输入
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA,&GPIO_InitStructure);
// 设置PA.0为外部中断
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource0);
}
void EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; // 上升沿触发中断
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure; // 设置中断向量表起始地址
#ifdef VECT_TAB_RAM
NVIC_SetVectorTable(NVIC_VectTab_RAM,0x0);
#else
NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x0);
#endif
// NVIC优先级分组1
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
// 使能EXTI 0通道 0级先占优先级 0级次占优先级
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/******************************
文件:stm32f10x_it.c
作者:mxp20120501
******************************/
#include "stm32f10x_it.h"
void EXTI0_IRQHandler(void)
{
static u8 led=0;
u32 delay=2000000;
switch(led)
{
case 0: led++;
GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_2); break;
case 1: led++;
GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_3); break;
case 2: led++;
GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_4); break;
case 3: led=0;
GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_5); break;
default:GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
}
while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 1); // 等待按键释放
while(delay--); // 延时去抖动
EXTI_ClearFlag(EXTI_Line0); // 清除标志位
}
附:效果图

/******************************
文件:main.c
作者:mxp20120501
******************************/
#include "stm32f10x_lib.h"
void RCC_Configuration(void);
void GPIO_Configuration(void);
void NVIC_Configuration(void);
void EXTI_Configuration(void);
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
NVIC_Configuration();
EXTI_Configuration();
GPIO_RestBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
while(1);
}
void RCC_Configuration(void)
{
ErrorStatus HSEStartUpStatus;
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON); // 开启外部高速晶振
HSEStartUpStatus = RCC_WaitForHSEStartUp(); // 等待晶振起振
if(HSEStartUpStatus == SUCCESS)
{
FLASH_SetLatency(FLASH_Latency_2); // 2个等待周期
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); // 使能FLASH预取缓冲
RCC_HCLKConfig(RCC_SYSCLK_Div1); RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_PCLK2Config(RCC_HCLK_Div1);
RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_9);
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while(RCC_GetSYSCLKSource() != 0x08);
}
RCC_APB2PeriphClockCmdRCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOE,ENABLE);
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
// 设置 PE.2 PE.3 PE.4 PE.5 为推挽输出,最大翻转频率2MHz
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOE,&GPIO_InitStructure);
// 设置PA.0浮空输入
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA,&GPIO_InitStructure);
// 设置PA.0为外部中断
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource0);
}
void EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; // 上升沿触发中断
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure; // 设置中断向量表起始地址
#ifdef VECT_TAB_RAM
NVIC_SetVectorTable(NVIC_VectTab_RAM,0x0);
#else
NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x0);
#endif
// NVIC优先级分组1
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
// 使能EXTI 0通道 0级先占优先级 0级次占优先级
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/******************************
文件:stm32f10x_it.c
作者:mxp20120501
******************************/
#include "stm32f10x_it.h"
void EXTI0_IRQHandler(void)
{
static u8 led=0;
u32 delay=2000000;
switch(led)
{
case 0: led++;
GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_2); break;
case 1: led++;
GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_3); break;
case 2: led++;
GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_4); break;
case 3: led=0;
GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_5); break;
default:GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
}
while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 1); // 等待按键释放
while(delay--); // 延时去抖动
EXTI_ClearFlag(EXTI_Line0); // 清除标志位
}
附:效果图

9楼
今天上午调好了SD卡的基本读写程序,下午调VS1003的程序没调好,正弦测试都没声音,郁闷啊,明天继续,等调好了搞个播放MP3的视频给大家看看,哈哈……

共10条
1/1 1 跳转至页
回复
打赏帖 | |
---|---|
汽车电子中巡航控制系统的使用被打赏10分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 | |
分享电子控制安全气囊计算机知识点被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【OZONE】使用方法总结被打赏20分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K314】芯片启动流程分析被打赏40分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K146】S32DS RTD 驱动环境搭建被打赏12分 | |
【分享开发笔记,赚取电动螺丝刀】【IAR】libc标注库time相关库函数使用被打赏23分 | |
LP‑MSPM0L1306开发版试用结果被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【LP-MSPM0L1306】适配 RT-Thread Nano被打赏23分 |