[STM32F1] STM32 内部时钟输出PA.8(MCO) 如何实现

[复制链接]
964|2
 楼主| 肥羊 发表于 2018-9-13 17:09 | 显示全部楼层 |阅读模式
下面是我的实现代码但是PA8 还是没有输出试了几块板一样没有输出
  1. void MCO_GPIO_Init(void)
  2. {
  3.         GPIO_InitTypeDef GPIO_InitStructure;
  4.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO,ENABLE);
  5.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
  6.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  7.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  8.         GPIO_Init(GPIOA,&GPIO_InitStructure);
  9.         RCC_MCOConfig( RCC_MCO_HSI);
  10. }
mmuuss586 发表于 2018-12-23 17:50 | 显示全部楼层
程序好像么没啥问题;
yzzly 发表于 2018-12-24 16:09 | 显示全部楼层
本帖最后由 yzzly 于 2018-12-24 16:11 编辑

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;                                                                        //PA8-
        #if(MCO1)                                                                                                                 //时钟输出
        {
                GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
                GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
                RCC->CFGR = RCC->CFGR | (MCO1_PllClk << 21);                                             //选择系统时钟输出到MCO1引脚
                RCC->CFGR = RCC->CFGR | ((MCO1_ClkPreDiv4+2) << 24);                              //系统时钟4分频后输出
                GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_MCO);
        }
        #else                                                                                                                       //普通IO
        {
                GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;  
                GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
        }
        #endif
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
        GPIO_Init(GPIOA, &GPIO_InitStructure);
您需要登录后才可以回帖 登录 | 注册

本版积分规则

38

主题

287

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部