请教下PSoC4的定时器的用法

[复制链接]
1622|7
 楼主| zhengbo7hui 发表于 2015-6-24 16:38 | 显示全部楼层 |阅读模式
对PSoC4的定时器还是不是很了解,请教下
heping517 发表于 2015-6-24 16:45 | 显示全部楼层
#include <device.h>

uint32 InterruptCnt;


/*******************************************************************************
* Define Interrupt service routine and allocate an vector to the Interrupt
********************************************************************************/
CY_ISR(InterruptHandler)
{
        /* Clear Inerrupt */
           Timer_ClearInterrupt(Timer_INTR_MASK_CC_MATCH);
   
        /* Increment the Counter to indicate the keep track of the number of
     * interrupts received */
    InterruptCnt++;   
}

void main()
{
    CyDelay(50);
   
    /* Enable the global interrupt */
    CyGlobalIntEnable;
   
    /* Enable the Interrupt component connected to interrupt */
    CC_ISR_StartEx(InterruptHandler);

        /* Start the components */
    Timer_Start();
    LCD_Start();
   
    /* Display Timer on LCD */
    LCD_Position(0u, 0u);
    LCD_PrintString("Timer");

    for(;;)
    {
        /* To display Period on LCD */
        LCD_Position(0u, 7u);
        LCD_PrintInt16(Timer_ReadPeriod());

        /* To display Capture value on LCD */
        LCD_Position(0u, 12u);
        LCD_PrintInt16(Timer_ReadCapture());

        /* To display count on LCD */
        LCD_Position(1u, 0u);
        LCD_PrintInt16(Timer_ReadCounter());
        
        /* To display Interrupt count on LCD */
        LCD_Position(1u, 5u);
        LCD_PrintString("IntCnt:");
        LCD_PrintInt16(InterruptCnt);
               
                CyDelay(100u);
    }
}
heping517 发表于 2015-6-24 17:00 | 显示全部楼层
要不

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
heping517 发表于 2015-6-24 17:01 | 显示全部楼层
夺得

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
heping517 发表于 2015-6-24 17:01 | 显示全部楼层
检查

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
heping517 发表于 2015-6-24 17:02 | 显示全部楼层
tt

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
heping517 发表于 2015-6-24 17:02 | 显示全部楼层
rew

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
heping517 发表于 2015-6-24 17:02 | 显示全部楼层
we

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

50

主题

502

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部