Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Defines the base address of the memories and peripherals */
- #include "../../../inc/hw_memmap.h"
- /* Defines the common types and macros */
- #include "../../../inc/hw_types.h"
- #include "../../../inc/hw_timer.h"
- #include "../../../driverlib/pin_map.h"
- /* Defines and Macros for GPIO API */
- #include "../../../driverlib/gpio.h"
- /* Prototypes for the system control driver */
- #include "../../../driverlib/sysctl.h"
- #include "../../../driverlib/adc.h"
- #include "../../../driverlib/uart.h"
- #include "../../../driverlib/interrupt.h"
- #include "../../../driverlib/uartstdio.h"
- #include "driverlib/timer.h"
- void UartInit(void)
- {
- // Enable GPIO port A which is used for UART0 pins.
- SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
- SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
- /* Make the UART pins be peripheral controlled. */
- GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
- // Initialize the UART for console I/O.
- UARTStdioInit(0);
- }
- void TimerInit(void)
- {
- /* The Timer0 peripheral must be enabled for use. */
- SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
- SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
- // GPIOPinConfigure(CCP1_PIN);
- GPIOPinTypeTimer(GPIO_PORTC_BASE, GPIO_PIN_5);
- // Configure Timer0B as a 16-bit periodic timer.
- TimerConfigure(TIMER0_BASE, TIMER_CFG_B_PWM | TIMER_CFG_B_PERIODIC);
- // Set the Timer0B load value to 1ms.
- TimerLoadSet(TIMER0_BASE, TIMER_B, SysCtlClockGet());
- // Set the Timer0B match value to load value / 3.
- TimerMatchSet(TIMER0_BASE, TIMER_B, TimerLoadGet(TIMER0_BASE, TIMER_B) / 3);
- /* Control the Timer Level */
- //TimerControlLevel(TIMER0_BASE, TIMER_B, true);
- /* Enable Timer0B. */
- TimerEnable(TIMER0_BASE, TIMER_B);
- }
- int main(void)
- {
- /*Set the clocking to directly run from the crystal at 7.37MHz*/
- SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_7_37MHZ);
- /* UART config */
- UartInit();
- TimerInit();
- while(1)
- {
- UARTprintf("Timer %40d\r",TimerValueGet(TIMER0_BASE, TIMER_B));
- SysCtlDelay(SysCtlClockGet()/12);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement