为什么探索者485程序可以不使能PG8的时钟

2019-07-20 12:52发布

void RS485_Init(u32 bound)
{           
       
  GPIO_InitTypeDef GPIO_InitStructure;
        USART_InitTypeDef USART_InitStructure;
        NVIC_InitTypeDef NVIC_InitStructure;
       
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE); //GPIOA±
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);//唀匀ART2±
       
  //2
        GPIO_PinAFConfig(GPIOA,GPIO_PinSource2,GPIO_AF_USART2); //GPIOA2唀匀ART2
        GPIO_PinAFConfig(GPIOA,GPIO_PinSource3,GPIO_AF_USART2); //GPIOA3唀匀ART2
       
        //USART2   
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; //GPIOA2GPIOA3
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;        //100MHz
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //ì
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //
        GPIO_Init(GPIOA,&GPIO_InitStructure); //倀A2倀A3
       
        //PG8ì485  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; //GPIOG8
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;        //100MHz
        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //ì
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //
        GPIO_Init(GPIOG,&GPIO_InitStructure); //倀G8

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。