当前位置:网站首页>GPIO novice

GPIO novice

2022-06-23 09:12:00 July meteor

1,GPIO Seven registers of :

Two 32 Bit configuration register :GPIOx_CRL,GPIOx_CRH          (x=A,B,C,D,E)

Two 32 Bit data register :GPIOx_IDR,GPIOx_ODR

One 16 Position position / Reset register :GPIOx_BSRR

One 16 Bit reset register :GPIOx_BRR

One 32 Bit lock register :GPIOx_LCKR

2,GOIO operation :

Output drive circuit :

Inside ( Write operations )--> Bit settings / Reset register --> Output data register --> Output control --

Input drive circuit :

Analog input , Both pull-up and pull-down switches are off , Floating input

Universal (GPIO) And reuse (AFIO) function

Input : Enter the float , Input pull-up , Type in the dropdown , Analog input

Output : Open drain output , Push pull output , Push pull multiplexed output , Open drain multiplexing

3,GPIO Port bit configuration

CRL Control register , Two bits control one pin ,CRL Control the lower eight digits ,CRH Control high eight bits

IDR Input data register , Use only low 16 One bit data , Each bit controls one pin

ODR The function of output data register is the same as above , high 16 Bit function reserved .

 

GPIO Register operation :

1. High pin output / Low level

GPIOA->CRL = 0x33;
GPIOA->ODR = 0x0000;   //0
GPIOA->ODR = 0x3;      //1

2.GPIOA_Pin_0 Status of with GPIOA_Pin_8 The state of change

       1.GPIOA Of 0 Feet as output ,50MHZ;GPIOA Of 8 Feet as input

       2.GPIOA_Pin_0 == GPIOA_Pin_8

       GPIOA->CRL = 0x03;     //0 Foot push-pull output ,50MHZ

       GPIOA->CRH = 0x04;     //8 Foot float input

  while(1)

  {

      if((GPIOA->IDR&0x0100) == 0x0100)

            GPIOA->ODR = 0x01;

     else

            GPIOA->ODR = 0x00;

  }

 

原网站

版权声明
本文为[July meteor]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230858453065.html