input , output, analog ,alternat
estados logicos para lectura de pines voltaje 0-3.3v
MICROS Y
|
LABORATORIOS
SESIÓN 3. MODULO DE ENTRADA/SALIDA –
GPIO (GENERAL PURPOSE INPUT/OUTPUT)
ING. OLGUER S. MORALES V. - MBA 1
ING. OLGUER S. MORALES V. - MBA 2
operaciones de hexa y binario (compuertas or(agrega 1) and (agrega 0) xor(cambia el
primero se usa la compuerta and y luego la or simbolos and & y or |
estado del pin))
unidad logica para poner el numero en lugar especifico del registro 1UL=01 ,
4bits -1hexa
2UL=10 , 3UL=11, ~3UL=0 0
poner el registro en cero &=0x0;
1UL>>0*2( EL CERO ES EL PIN Y EL DOS SE REFIRE A LAS CASILLAS O BITS )
configuracion de los pines |=0x reprecentacion del los binarios en hexa;
GPIO port mode register (GPIOx_MODER) (x =A..K) configuracion de cada pin |=0x5555; (reprecentacion de 01 en hexa)
ING. OLGUER S. MORALES V. - MBA 3
primero hay que borrar lo que hay en la trama del registro
GPIO port output type register (GPIOx_OTYPER) (x = A..K)
ING. OLGUER S. MORALES V. - MBA 4
CONFIGURACION DE LA VELOCIDAD DE LOS PINES DE SALIDA
GPIOB_OSPEEDR-(1UL>>0*2)
GPIO port output speed register (GPIOx_OSPEEDR) (x = A..K)
ING. OLGUER S. MORALES V. - MBA 5
GPIO port pull-up/pull-down register (GPIOx_PUPDR) (x = A..K)
ING. OLGUER S. MORALES V. - MBA 6
LEEMOS DATOS int estado
posiciones : 0x0;0x1:0x2;0x4;0x8; if (GPIOB_IDR&0X8)==0X8){ estado=1;}
GPIOB_IDR&0X4 else { estado =0}
GPIOB_IDR&=0X20 0
if (GPIOB_IDR&=0X20){}
GPIO port input data register (GPIOx_IDR) (x = A..K)
RCC=AHB1ENR (PRENDE LOS PINES)
RCC=AHB1ENR =0X6; PRENDE LOS PUERTOS INDICADOS
ING. OLGUER S. MORALES V. - MBA 7
para prenderlos uno por uno
|=0*1, &=0*0 apaga y prende en la posición cero
SACAMOS DATOS
gpiob_odr |=(1ul>>0) solo colocamos la posición ya que
GPIOB_ODR=0XHEX;
solo hay un numero de bits
GPIO port output data register (GPIOx_ODR) (x = A..K)
LEDS PUERTO B PULSADORES PUERTO C
PRENDE RCC=GPIO_ODR|=0X4081; GPIOC_IDR&=0X2000
APAGA RCC=GPIO_ODR&=0X0;
ING. OLGUER S. MORALES V. - MBA 8
RCC AHB1 peripheral clock register (RCC_AHB1ENR)
ING. OLGUER S. MORALES V. - MBA 9
EJEMPLOS / EJERCICIOS
ING. OLGUER S. MORALES V. - MBA 10
ING. OLGUER S. MORALES V. - MBA 11
Preguntas
ING. OLGUER S. MORALES V. - MBA 12