OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3353|回复: 0

重新设置系统的设置配置,编译没错,下到迷你版不能运行,求指教

[复制链接]

4

主题

5

帖子

0

精华

新手上路

积分
49
金钱
49
注册时间
2015-10-19
在线时间
4 小时
发表于 2015-10-19 16:38:58 | 显示全部楼层 |阅读模式
5金钱
[mw_shl_code=c,true]#include "stm32f10x.h" #include "delay.h" /************************************************ ALIENTEK ????STM32F103??·?°????é0 ?¤????°? ************************************************/ void RCC_Init(void); void USART1_IRQHandler(void); void USART1_Init(void); int main(void) { RCC_Init(); USART1_Init(); USART1_IRQHandler(); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //??????????·?×é while(1) { GPIO_ResetBits(GPIOA,GPIO_Pin_3); delay_ms(300); GPIO_SetBits(GPIOA,GPIO_Pin_3); delay_ms(300); }; } void USART1_Init(void) { //GPIO?????è?? GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOD,ENABLE); //GPIO???±???è?? RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE); //?®???±???è?? RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //RX GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //TX GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; //LED0-->D.2 ???????? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //???ì???? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO????????50MHz GPIO_Init(GPIOA, &GPIO_InitStructure); //?ù???è?¨??????????GPIOD.2 GPIO_SetBits(GPIOA,GPIO_Pin_3); //PD.2 ?????? GPIO_Init(GPIOA, &GPIO_InitStructure); //USART ???????è?? USART_InitStructure.USART_BaudRate = 9600; //?¨???? USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //?????????÷ USART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx; //?????? USART_InitStructure.USART_Parity = USART_Parity_No; //???é?? USART_InitStructure.USART_StopBits = USART_StopBits_1; //?????? USART_InitStructure.USART_WordLength = USART_WordLength_8b; //×??¤ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3 ; //??????????3 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //×???????3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ?¨?????? NVIC_Init(&NVIC_InitStructure); //?ù?????¨????????????VIC?????÷ USART_Init(USART1,&USART_InitStructure); //?ù?????¨????????????VIC?????÷ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //?????®?????????? USART_Cmd(USART1,ENABLE); //?®?????? } void USART1_IRQHandler(void) { u8 onyourmark; if(USART_GetITStatus(USART1, USART_IT_RXNE)) // ???????? { onyourmark = USART_ReceiveData(USART1); //?????????®???????? USART_SendData(USART1, onyourmark); //·????????????? } } void RCC_Init(void) { ErrorStatus HSEStartUpStatus; NVIC_InitTypeDef NVIC_InitStructure; /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/ /* RCC system reset(for debug purpose) */ RCC_DeInit(); /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); /* ?????±?????????????????????±??/2?????à?·?????±?? ??????72M */ if(HSEStartUpStatus == SUCCESS) { /* Enable Prefetch Buffer */ // FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); /* Flash 2 wait state */ // FLASH_SetLatency(FLASH_Latency_2); /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* APB2 PCLK2 = HCLK */ RCC_PCLK2Config(RCC_HCLK_Div1); /* APB1 PCLK1 = HCLK/2 */ RCC_PCLK1Config(RCC_HCLK_Div2); /* APB1 ADCCLK = HCLK/8 */ RCC_ADCCLKConfig(RCC_PCLK2_Div8); /* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div2, RCC_PLLMul_9); // 16 /2 * 9 = 72 /* 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); }/* endof if(HSEStartUpStatus == SUCCESS) */ /* ?????±???????§°??????????·???? */ else /* elseof if (HSEStartUpStatus == SUCCESS) */ { while(1); // SYSRESET(); //???????? } /* Enable and configure RCC global IRQ channel */ NVIC_InitStructure.NVIC_IRQChannel = RCC_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } [/mw_shl_code]


正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-7-18 20:04

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表