Prof. Daniel Ponte, E.E. [email protected] Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 1 ARM – PERIFÉRICO - GPIO
Prof. Daniel Ponte, E.E.
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 1
ARM – PERIFÉRICO - GPIO
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 2
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 3
PO
RTA
SG
PIOPeriféricos ARM - GPIO
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 4
PO
RTA
SG
PIOPeriféricos ARM
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 5
PORTAS GPIO SÃO MAPEADAS NA MEMÓRIAPeriféricos ARM - GPIO
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 6
PORTAS GPIO SÃO MAPEADAS NA MEMÓRIAPeriféricos ARM - GPIO
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 7
PORTAS GPIO SÃO MAPEADAS NA MEMÓRIAPeriféricos ARM - GPIO
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte8
PORTAS GPIO SÃO MAPEADAS NA MEMÓRIAPeriféricos ARM - GPIO
4K
DEC 4096HEX 1000
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 9
MEMÓRIA CONTÉM CÓDIGOS E DADOS
GPIO SÃO PORTAS DE ENTRADA E SAÍDA DE ACESSO A DISPOSITIVOS: GPIO DE PROPÓSITO GERAL – INTERFACE COM LEDS... GPIO DE FUNÇÃO ESPECIAL – ADC, TIMER, UART, ETC
Periféricos ARM - GPIO
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 10
Periféricos ARM - GPIO
PC0-PC3 – JTAG -DEBUG
BARRAMENTOAPB – ADVANCED PERIPHERAL BUS2 CICLO PARA ACESSAR PERIFÉRICOS
AHB – ADVANCED HIGH-PERFORMANCE BUS1 CICLO PARA ACESSAR PERIFÉRICOS
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 11
Periféricos ARM - GPIO BARRAMENTOAPB – ADVANCED PERIPHERAL BUS
AHB – ADVANCED HIGH-PERFORMANCE BUS
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 12
PORTAS GPIO
Periféricos ARM - GPIO Pinos suporta 5V/3.3VTodas as portas podem gerar interrupção Mascarável Borda de descida/subida Nível
Bit BandFonte de disparo A/D e DMAHibernação – Status IO dos pinos são mantidosTodos os pino têm entrada controlado por Schmitt
TriggerPull Up/Pull DownSlew Rate
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 13
Periféricos ARM - GPIO
CLOCK DO SISTEMA
RELAÇÃO CUSTO BENEFÍCIO ENTRE:VELOCIDADE DE EXECUÇÃO DAS INSTRUÇÕES E O CONSUMO DE ENERGIA
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 14
Periféricos ARM - GPIO
1 - Configura o OSCSRC2 =00 : SELECIONA O OSCILADOR MAIN
2 – Configura
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 15
CLOCK PRICIPAL
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 16
CLOCK PRICIPAL – CLOCK SYSTEM
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 17
CLOCK PRICIPAL
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 18
Periféricos ARM - GPIO
GPIO CONFIG. SAÍDAHABILITAR CLOCK DA GPIOPORTA CONTROLADORA DA GPIOFUNÇÃO ALTERNATIVA DA GPIODIREÇÃO DO DADO: SAÍDAFUNÇÃO CONTROLADA GPIO/PERIF.ENVIAR DADO PARA PORTA F
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 19
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 20
Periféricos ARM - GPIO
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 21
CONFIGURANDO A PORTA F GPIO COMO SAÍDA
Periféricos ARM - GPIO
HABILITAR O CLOCK
F E D C B A
1 0 0 0 0 0 0x20
SYSCTL_RCGCGPIO_R |= 0x20; // ativa a porta F
|= Equivale um OU e uma atribuição
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 22
CONTROLADOR DA PORTA GPIO GPIOPCTL (PORTA CONTROLADORA DA GPIO)
Periféricos ARM - GPIO
GPIO_PORTF_PCTL_R = 0x00000000;
// Habilita todos os pinos como periférico GPIO (PMC-Port Mux Control)
GPIOPCTL – Registrador usado em conjunto com GPIOAFSEL e especifica o tipo
de periférico a ser usado na porta.
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 23
DESABILTA A PORTA F COMO FUNÇÃO ALTERNATIVA
Periféricos ARM - GPIO
0 – A função é controlada pelo registradores da GPIO1 -A função é controlada pelos registradores dos Periféricos
GPIO_PORTF_AFSEL_R = 0x00;
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 24
CONFIGURANDO A PORTA F GPIO COMO SAÍDAPeriféricos ARM - GPIO
HABILITAR A PORTA COMO SAÍDA
GPIO_PORTF_DIR_R |= 0x0E; // ativa a porta F
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 1 1 1 0
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 25
CONFIGURANDO A PORTA F GPIO COMO SAÍDAPeriféricos ARM - GPIO
HABILITAR A PORTA COMO SAÍDA
GPIO_PORTF_DIR_R |= 0x0E; // ativa a porta F
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 26
CONFIGURANDO A PORTA F COMO DIGITAL
Periféricos ARM - GPIO
GPIO_PORTF_DEN_R |= 0x0E; // enable digital I/O on PF3-1
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 1 1 1 1 1
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 27
ESCREVENDO UM DADO PARA SAÍDA D1
Periféricos ARM - GPIO
PF7 PF6 PF5 PF4 PF3 PF2 PF1 PF0
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 1 0
GPIO_PORTF_DATA_R = (0x02);
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 28
Periféricos ARM - GPIO
USANDO APIs
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 29
Periféricos ARM - GPIO int main(void){
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
while(1)
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1| GPIO_PIN_2| GPIO_PIN_3,0x02);
SysCtlDelay(2000000);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00);
SysCtlDelay(2000000);
}}
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 30
Periféricos ARM - GPIO
ENTRADA E SAÍDA GPIOCLOCKDESBLOQUEIO DA PORTA PF0 PORTA CONTROLADORA DA GPIOFUNÇÃO ALTERNATIVA DA GPIODIREÇÃO DO DADO: SAÍDA/ENTRADAHABOLITA A PORTA COMO DIGITALHABILITA PINOS ENTRADA PULL UP
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 31
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 32
CONFIGURANDO A PORTA F GPIO COMO ENTRADA/ SAÍDAPeriféricos ARM - GPIO
HABILITAR O CLOCK
DESBLOQUEIO DA PORTA (P
SYSCTL_RCGCGPIO_R |= 0x20; // ativa a porta F
GPIO_PORTF_LOCK_R = 0x4C4F434B; // 2) DESBLOQUEIO DA GPIO Port F
GPIO_PORTF_CR_R = 0x1F; // PERMITIR MUDANÇAS PARA PF4-0
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 33
CONFIGURANDO A PORTA F GPIO COMO ENTRADA/ SAÍDAPeriféricos ARM - GPIO
Seleciona Periférico
GPIO_PORTF_PCTL = 0x00000000; //
GPIO_PORTF_AFSEL = 0x00; //
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 34
CONFIGURANDO A PORTA F GPIO COMO SAÍDA/ENTRADA
Periféricos ARM - GPIO
HABILITAR A PORTA COMO SAÍDA/ENTRADA
GPIO_PORTF_DIR_R |= 0x0E; // ativa a porta F
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 1 1 1 0
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 35
CONFIGURANDO A PORTA F COMO DIGITAL
Periféricos ARM - GPIO
GPIO_PORTF_DEN_R |= 0x1F;
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 1 1 1 1 1
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 36
CONFIGURANDO A PORTA F COMO PULL - UPPeriféricos ARM - GPIO
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 1 0 0 0 1
GPIO_PORTF_DEN_R |= 0x1F;
GPIO_PORTF_PUR_R = 0x11;
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 37
Periféricos ARM - GPIO
void GPIO_Conf(void){
SYSCTL_RCGCGPIO_R |= 0x00000020; // (a) activate clock for port FGPIO_PORTF_LOCK_R = 0x4C4F434B; // 2) DESBLOQUEIO DA GPIO Port FGPIO_PORTF_CR_R = 0x1F; // PERMITIR MUDANÇAS PARA PF4-0
GPIO_PORTF_AFSEL_R =0x00; // Desabilita a função alternativaGPIO_PORTF_PCTL_R = 0x00000000; // Habilita o periférico GPIO
GPIO_PORTF_DIR_R = 0x0E; // Configura PF4 e PF0 como entrada (0) e PF 1-2-3 como saídaGPIO_PORTF_DEN_R |= 0x1F; // Habilita o pino como DigitalGPIO_PORTF_PUR_R = 0x11; // Habilita os pinos 0 e 4 como Pull-Up (saída em nível alto)
}
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 38
Periféricos ARM - GPIO
USANDO APIs
Curso FPGA - Instituto Federal do Piauí / Prof.Daniel F Ponte 39
Periféricos ARM - GPIO int main(void){
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;HWREG(GPIO_PORTF_BASE + GPIO_O_CR) = 0x01;HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) =0x0;
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_4);
GPIOPadConfigSet(GPIO_PORTF_BASE,0x11,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD_WPU);
while(1){
ui8Pins = GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_0| GPIO_PIN_4);
if(ui8Pins == 0x11){