打印
[CC3200]

CC3200 Timer Application

[复制链接]
677|12
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
概述
每个 GPTM(通用定时器模块)模块可以作为两个 16 位定时器/计数器(称为定时器 A 和定
时器 B),可以配置为独立运作模式来作为定时器或事件计数器,或联合起来作为一个 32 位定
时器。  

使用特权

评论回复
评论
dirtwillfly 2019-7-31 21:03 回复TA
感谢分享 

相关帖子

沙发
xinxianshi| | 2019-7-31 17:54 | 只看该作者
多谢分享,可惜你概述完了没下文了。

使用特权

评论回复
板凳
gaoke231|  楼主 | 2019-7-31 18:24 | 只看该作者
定时器也可以用来触发 µDMA 传输。
支持以下操作模式:
 16 或 32 位的可编程一次性定时器;
 16 或 32 位的可编程周期定时器;
 16 位的通用定时器和一个 8 位预定标器。

使用特权

评论回复
地板
gaoke231|  楼主 | 2019-7-31 18:25 | 只看该作者
这个应用程序的目的是展示定时器 DriverLib 的 API 的使用。 使用 16 位定时器产生中
断从而切换 GPIO 的状态(led)。
两个具有不同超时值(一个是另一个的两倍)的定时器被设置去切换两个不同的接有
LED 灯的 GPIO,展示 LED 灯闪烁的效果。

使用特权

评论回复
5
gaoke231|  楼主 | 2019-7-31 18:27 | 只看该作者
static volatile unsigned long g_ulSysTickValue;
static volatile unsigned long g_ulBase;
static volatile unsigned long g_ulRefBase;
static volatile unsigned long g_ulRefTimerInts = 0;
static volatile unsigned long g_ulIntClearVector;
unsigned long g_ulTimerInts;

使用特权

评论回复
6
gaoke231|  楼主 | 2019-7-31 18:27 | 只看该作者
void
TimerBaseIntHandler(void)
{
    //
    // Clear the timer interrupt.
    //
    Timer_IF_InterruptClear(g_ulBase);

    g_ulTimerInts ++;
    GPIO_IF_LedToggle(MCU_GREEN_LED_GPIO);
}

使用特权

评论回复
7
gaoke231|  楼主 | 2019-7-31 18:27 | 只看该作者
void
TimerRefIntHandler(void)
{
    //
    // Clear the timer interrupt.
    //
    Timer_IF_InterruptClear(g_ulRefBase);

    g_ulRefTimerInts ++;
    GPIO_IF_LedToggle(MCU_RED_LED_GPIO);
}

使用特权

评论回复
8
gaoke231|  楼主 | 2019-7-31 18:28 | 只看该作者
static void
BoardInit(void)
{
/* In case of TI-RTOS vector table is initialize by OS itself */
#ifndef USE_TIRTOS
  //
  // Set vector table base
  //
#if defined(ccs)
    MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
#endif
#if defined(ewarm)
    MAP_IntVTableBaseSet((unsigned long)&__vector_table);
#endif
#endif
    //
    // Enable Processor
    //
    MAP_IntMasterEnable();
    MAP_IntEnable(FAULT_SYSTICK);

    PRCMCC3200MCUInit();
}

使用特权

评论回复
9
gaoke231|  楼主 | 2019-7-31 18:28 | 只看该作者
int
main(void)
{
    //
    // Initialize board configurations
    BoardInit();
    //
    // Pinmuxing for LEDs
    //
    PinMuxConfig();
    //
    // configure the LED RED and GREEN
    //
    GPIO_IF_LedConfigure(LED1|LED3);

    GPIO_IF_LedOff(MCU_RED_LED_GPIO);
    GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);

    //
    // Base address for first timer
    //
    g_ulBase = TIMERA0_BASE;
    //
    // Base address for second timer
    //
    g_ulRefBase = TIMERA1_BASE;
    //
    // Configuring the timers
    //
    Timer_IF_Init(PRCM_TIMERA0, g_ulBase, TIMER_CFG_PERIODIC, TIMER_A, 0);
    Timer_IF_Init(PRCM_TIMERA1, g_ulRefBase, TIMER_CFG_PERIODIC, TIMER_A, 0);

    //
    // Setup the interrupts for the timer timeouts.
    //
    Timer_IF_IntSetup(g_ulBase, TIMER_A, TimerBaseIntHandler);
    Timer_IF_IntSetup(g_ulRefBase, TIMER_A, TimerRefIntHandler);

    //
    // Turn on the timers feeding values in mSec
    //
    Timer_IF_Start(g_ulBase, TIMER_A, 500);
    Timer_IF_Start(g_ulRefBase, TIMER_A, 1000);
       
    //
    // Loop forever while the timers run.
    //
    while(FOREVER)
    {
    }
}

使用特权

评论回复
10
gaoke231|  楼主 | 2019-7-31 18:29 | 只看该作者
#include "pinmux.h"
#include "hw_types.h"
#include "hw_memmap.h"
#include "hw_gpio.h"
#include "pin.h"
#include "gpio.h"
#include "prcm.h"

//*****************************************************************************
void PinMuxConfig(void)
{
        //
    // Enable Peripheral Clocks
    //
        PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);

        //
    // Configure PIN_18 for GPIO Output
    //
        PinTypeGPIO(PIN_18, PIN_MODE_0, false);
        GPIODirModeSet(GPIOA3_BASE, 0x10, GPIO_DIR_MODE_OUT);

        //
    // Configure PIN_53 for GPIO Output
    //
        PinTypeGPIO(PIN_53, PIN_MODE_0, false);
        GPIODirModeSet(GPIOA3_BASE, 0x40, GPIO_DIR_MODE_OUT);
}

使用特权

评论回复
11
gaoke231|  楼主 | 2019-7-31 18:30 | 只看该作者
xinxianshi 发表于 2019-7-31 17:54
多谢分享,可惜你概述完了没下文了。

在更新呢

使用特权

评论回复
12
xinxianshi| | 2019-7-31 18:33 | 只看该作者
哈哈,不好意思,被我占楼破坏队形。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

54

主题

1310

帖子

5

粉丝