完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
程序如下:
调试卡在了程序中加粗一句,求助! 谢谢各路大神!!! #include <STM32f4xx.h> #include void RCC_Configuration(void); //ʱÖÓÅäÖà void USART1_Configuration(void); //´®¿Ú1ÅäÖà int main(void) { uint16_t i = 0; RCC_Configuration(); USART1_Configuration(); //USART1_NVIC_Configuration(); //DMA_Configuration(); //DMA_NVIC_Configuration(); while(1) { if(USART_GetFlagStatus(USART1,USART_IT_RXNE) == SET) { USART_SendData(USART1,USART_ReceiveData(USART1)); for(i = 0;i < 500;i++); } } } /*ʱÖÓ*/ void RCC_Configuration(void) //ʱÖÓÅäÖà { ErrorStatus HSEStartUp; //ö¾ÙÐͱäÁ¿£¬½ÓÊÜHSEÆðÕñ·µ»ØÖµ RCC_DeInit(); //ȱʡRCC¼Ä´æÆ÷ RCC_HSEConfig(RCC_HSE_ON); //¿ªÆôHSE,HSE=8M HSEStartUp = RCC_WaitForHSEStartUp(); //µÈ´ýHSEÆðÕñ if(HSEStartUp == SUCCESS) //ÆðÕñ³É¹¦ { RCC_PLLConfig(RCC_PLLSource_HSE,4,288,4,8); //VCOIN=4M,VCOOUT=288M,PLL=72M,others=36M RCC_HCLKConfig(RCC_SYSCLK_Div1); //AHB=SYSCLK 72M RCC_PCLK1Config(RCC_HCLK_Div2); //CLK1=AHB/2 36M RCC_PCLK2Config(RCC_HCLK_Div2); //CLK2=AHB/2 36M /*ÑÓʱFLASH 2¸öÖÜÆÚ£¬Ê¹ÄÜÔ¤¶Á»º´æ£¨±ØÐëµÄ£©*/ FLASH_SetLatency(FLASH_Latency_2); FLASH_PrefetchBufferCmd(ENABLE); RCC_PLLCmd(ENABLE); //ʹÄÜPLL while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET); //µÈ´ýPLL¾ÍÐ÷ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); //Ñ¡ÔñPLLΪSYSCLK while(RCC_GetSYSCLKSource() != 0x08); //µÈ´ýϵͳʱÖÓ¾ÍÐ÷ } } /*´®¿Ú1*/ void USART1_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; //³õʼ»¯GPIO½á¹¹Ìå USART_InitTypeDef USART_InitStructure; //³õʼ»¯USART½á¹¹Ìå RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE); //ʹÄÜGPIOAʱÖÓ RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE); //ʹÄÜUSART1ʱÖÓ /*ÅäÖÃUSART1µÄGPIO*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //Ñ¡ÖйܽÅ9 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; //¸´Óù¦ÄÜ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //ÍÆÍìÊä³ö GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //I/O¿Ú×î¸ß· תƵÂÊ50MHz GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //ÉÏÀ µç×è GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //¿ªÂ©Êä³ö GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //ÎÞÉÏÏÂÀ µç×è GPIO_Init(GPIOA,&GPIO_InitStructure); /*ÅäÖÃUSART1µÄģʽ*/ USART_InitStructure.USART_BaudRate = 9600; //²¨ÌØÂÊΪ9600 USART_InitStructure.USART_WordLength = USART_WordLength_8b; //×Ö³¤Îª8bit USART_InitStructure.USART_StopBits = USART_StopBits_1; //1λֹͣλ USART_InitStructure.USART_Parity = USART_Parity_No; //ÎÞÆæżЧÑé USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //²»Ö§³ÖÁ÷Á¿¿ØÖÆ USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //ģʽ USART_Init(USART1,&USART_InitStructure); //USART_ITConfig(USART1,USART_IT_RXNE,ENABLE); //ʹÄÜUSART1½ÓÊܼĴæÆ÷·Ç¿Õʱ²úÉúÖÐ¶Ï USART_Cmd(USART1,ENABLE); //ʹÄÜ´®¿Ú1 //USART_ClearFlag(USART1,USART_FLAG_TC); } |
|
相关推荐
2个回答
|
|
|
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-mfgtools烧录流程之烧写原理
321 浏览 0 评论
请问SPH0641LU4H这款麦克风如何在不使用I2S的情况下,单纯通过GPIO来进行驱动且正常读取数据呢
325 浏览 0 评论
296 浏览 0 评论
《DNESP32S3使用指南-IDF版_V1.6》第三十六章 照相机实验
313 浏览 0 评论
STM32模拟eeprom只有起始地址0x8001000正常其他地址都会造成单片机运行不正常怎么回事
276 浏览 1 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
12079 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-31 05:47 , Processed in 0.578254 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号