Professional Documents
Culture Documents
Exemplo 3
Exemplo 3
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/uart.h"
#include "driverlib/pin_map.h"
#include "utils/uartstdio.h"
#include "driverlib/interrupt.h"
#include "inc/hw_ints.h"
#include "driverlib/timer.h"
#include "inc/hw_timer.h"
#define GPIO_PORTF_LOCK_R (*((volatile uint32_t *)0x40025520))
#define GPIO_PORTF_CR_R (*((volatile uint32_t *)0x40025524))
#define MULT_TIMER 1 // Ajuste do Timer para teste
uint8_t LED=4, flag=0;
GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_0|GPIO_PIN_4,
GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
// Habilitao do TIMER0
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); //Configura o Timer como peridico
Period = (SysCtlClockGet()*MULT_TIMER); // Recebe o valor do clock multiplicado por
uma varivel para o perodo
TimerLoadSet(TIMER0_BASE, TIMER_A, Period -1);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerEnable(TIMER0_BASE, TIMER_A);
IntPrioritySet(INT_TIMER0A, 0x10); // Setando prioridade
IntEnable(INT_TIMER0A);
ConfigureUART();
while(1)
{
//Observe que while(1) est vazio!
}
}