DM6437定时器使用
本人刚刚接触dm6437,写此文章主要是为了记录学习过程,如有错误,还请各位指点。
DM6437共有3个定时器,time0,time1,time2,time2只能作为开门狗使用。time0和time1可以配置为以下几种模式:
2. Program the VDD3P3V_PWDN register to power up the IO pins for Timer 0 and Timer 1
3. 设置时钟源 (CLKSRC bit in TCR).
4. 设置输出模式 (CP bit in TCR).
5. 选择输出脉冲宽度(PWID bit in TCR).
6. 外部时钟输入时选择是否需要6分频 (TINP0SEL bit in TIMERCTL in system module).
7. 是否需要反向(INVINP and INVOUTP bits in TCR).
8. Select 32-bit chained mode (TIMMODE bit in TCR).
9. Remove the timer from reset (TIM12RS and TIM34RS bits in TGCR).
10. 设置周期 (PRD12).
11. Select the desired timer prescaler value (PRD34).
12. 使能定时器(ENAMODE12 bit field in TCR).
2. 设置 VDD3P3V_PWDN 寄存器
3. 选择输出模式 (CP bit in TCR).
4. 选择脉冲宽度(PWID bit in TCR).
5. 外部时钟输入是否6分频 (TINP0SEL bit in TIMERCTL in system module).
6. 输出反向 (INVINP and INVOUTP bits in TCR).
7. 设置32bit非链模式 (TIMMODE bit in TGCR).
8. Remove the Timer 1:2 from reset (TIM12RS bit in TGCR).
9. 选择时钟周期Timer 1:2 (PRD12).
10. 选择时钟源 Timer 1:2 (CLKSRC12 bit in TCR).
11. 时能 Timer 1:2 (ENAMODE12 bit field in TCR).
配置Timer 3:4, 如下:
1. 选择32bit非链模式 (TIMMODE bit in TGCR).
3. 选择时钟周期Timer 3:4 (PRD34).
4. Select the desired prescaler value for Timer 3:4 (PSC34 bit in TGCR).
5. 使能Timer 3:4 (ENAMODE34 bit field in TCR).
/* ============================================================================* Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2006, 2007** Use of this software is controlled by the terms and conditions found* in the license agreement under which this software has been supplied.* ============================================================================*//** ============================================================================* @brief A simple example to demonstrate CSL 3.x register layer * usage and interrupts. ** @file interrupt_example.c** <b> Example description </b> * @verbatimThe interrupt example is a non-bios example that uses TIMER0 to generate cpu INT4. TIMER0 is configured in 32bit unchained once mode and its event is mapped CPU interrupt 4. The test enables TIMER0 and verifies that the interrupt service routine is executed when the period value is reached. A pass/fail status is returned to main.@endverbatim* * * @n <b> Procedure to run the example </b>* @verbatim1. Configure the CCS setup to work with the emulator being used.2. Please refer CCS manual for setup configuration and loading proper GEL file.3. Launch CCS.4. Open project Intc_example.pjt.5. Build the project and load the .out file for the project.@endverbatim** ============================================================================**/#include <stdio.h>
#include <soc.h>
#include <c6x.h>
#include <cslr_intc.h>
#include <cslr_tmr.h>
#include <cslr_psc.h>
#include <cslr_sys.h>static void setup(void);
static int test_interrupt(void);
extern void intcVectorTable(void);
static void device_init(void);const unsigned int TIMER_PERIOD = 0x00006978; // timer period setting
int intFlag=1; // interrupt flag CSL_TmrRegsOvly tmr0Regs = (CSL_TmrRegsOvly)CSL_TMR_0_REGS;
CSL_IntcRegsOvly intcRegs = (CSL_IntcRegsOvly)CSL_INTC_0_REGS;int main (void)
{// enable TIMER0 in MUX and PSCdevice_init(); // setup TIMER0 and interrupt setup();// test interrupt, returns 0 for pass and 1 for fail return(test_interrupt());
}void setup(void)
{// clear TIM12 register CSL_FINST(tmr0Regs->TIM12,TMR_TIM12_TIM12,RESETVAL);// select 32 bit unchained mode and take the timer out of resettmr0Regs->TGCR = CSL_FMKT(TMR_TGCR_TIMMODE,32BIT_UNCHAIN)| CSL_FMKT(TMR_TGCR_TIM12RS,NO_RESET);// set TIMER0 PRD1:2CSL_FINS(tmr0Regs->PRD12,TMR_PRD12_PRD12,TIMER_PERIOD);// map TIMER0 event to cpu int4CSL_FINS(intcRegs->INTMUX1, INTC_INTMUX1_INTSEL4,TIMER0_EVENT); // set ISTP to point to the vector table addressISTP = (unsigned int)intcVectorTable;// clear all interrupts, bits 4 thru 15ICR = 0xFFF0; // enable the bits for non maskable interrupt and CPUINT4 */IER |= 0x12; // enable interrupts, set GIE bit _enable_interrupts();
}int test_interrupt(void)
{printf("\nTesting CPU Interrupt 4 using TIMER0\n");// enable TIMER0 1:2 side, once modeCSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE12,EN_ONCE);printf("\nStarting TIMER0\n");// wait for TIMER0 to run to the period value and reset countwhile(CSL_FEXT(tmr0Regs->TIM12,TMR_TIM12_TIM12)!=0x0);if(intFlag!=0){printf("Error\n");printf("\nInterrupt test: FAILED\n");} elseprintf("\nInterrupt test: PASSED\n"); return(intFlag);
}interrupt void interrupt4(void)
{// disable TIMER0 1:2 sideCSL_FINST(tmr0Regs->TCR,TMR_TCR_ENAMODE12,DISABLE); // set the interrupt flag intFlag=0;
}void device_init(void)
{CSL_PscRegsOvly pscRegs = (CSL_PscRegsOvly)CSL_PSC_0_REGS;CSL_SysRegsOvly sysRegs = (CSL_SysRegsOvly)CSL_SYS_0_REGS;// enable TIMER0 in the PINMUX1 register
//使能time0sysRegs->PINMUX1 |= CSL_FMK(SYS_PINMUX1_TIM0BK,1); // ensure TIMER0 is powered
//io口电源设置sysRegs->VDD3P3V_PWDN |= CSL_FMKT(SYS_VDD3P3V_PWDN_TIMER0,POWERUP);// deassert TIMER0 local PSC reset and set NEXT state to ENABLEpscRegs->MDCTL[CSL_PSC_TIMER0] = CSL_FMKT( PSC_MDCTL_NEXT, ENABLE ) | CSL_FMKT( PSC_MDCTL_LRST, DEASSERT );// move TIMER0 PSC to Next statepscRegs->PTCMD = CSL_FMKT( PSC_PTCMD_GO0, SET );// wait for transitionwhile ( CSL_FEXT( pscRegs->MDSTAT[CSL_PSC_TIMER0], PSC_MDSTAT_STATE )!= CSL_PSC_MDSTAT_STATE_ENABLE );
}
说明:以上代码是在非bios模式下,使用TI的CSLR来完成的
DM6437定时器使用相关推荐
- 一文吃透JAVA定时器格式
JAVA 定时器时间格式 基本格式: [秒] [分] [小时] [日] [月] [周] [年] 序号 说明 是否必填 允许填写的值 允许使用的通配符 1 秒 是 0-59 , - ...
- Timer定时器开发
Timer定时器开发 定时器的作用是不占线程的等待一个确定时间,同样通过callback来通知定时器到期. 参考:https://github.com/sogou/workflow 定时器的创建 同样 ...
- linux定时器(crontab)实例
linux实验示例----实现每2分钟将"/etc"下面的文件打包存储到"/usr/lobal"目录下 ·Step1:编辑当前用户的crontab并保存 终端输 ...
- c语言程序设计分段定时器,单片机C语言编程定时器的几种表达方式
原标题:单片机C语言编程定时器的几种表达方式 吴鉴鹰单片机开发板地址 店铺:[吴鉴鹰的小铺] 地址:[https://item.taobao.com/item.htm?_u=ukgdp5a7629&a ...
- linux 内核按键抖动,Tiny4412 Linux驱动之按键(定时器防抖动) | 技术部落
按键抖动示意图 我们平常所用的按键为机械弹性开关,由于触点的弹性作用,按键在闭合时不会马上稳定的接通,而是有一段时间的抖动,在断开时也不会立即断开.抖动时间由按键的机械特性所决定,一般为5ms~10m ...
- mysql 定时器不能持续循环执行_定时器,不循环执行指定方法?如何解决?
⁽⁽ଘ你管我管你疯啊ଓ⁾⁾ 01-22 加粗 标红 插入代码 插入链接 插入图片 上传视频 请 登录 后发表内容 关闭 新增或编辑超链接 链接地址 关闭 插入视频 视频链接 messageScroll ...
- oracle定时器怎么开启,Oracle的定时器使用示例
下面是编程之家 jb51.cc 通过网络收集整理的代码片段. 编程之家小编现在分享给大家,也给大家做个参考. --Oracle定时job --数据库执行此脚本时时,请确保只执行一次,否则会引发错误! ...
- java 定时器获得外部参数_JMeter定时器使用小结
一.定时器的作用域 1.无论定时器位置在Sampler之前还是下面,定时器是在每个sampler(采样器)之前执行的,而不是之后: 2.当执行一个Sampler之前时,所有当前作用域内的定时器都会被执 ...
- PHP 毫秒级定时器,实现php毫秒定时器方法详解
描述 PHP编程语言是一种快速.简洁的服务端脚本编程语言,可以制作强大的交互性展现.在编程界PHP是完全免费的语言,在程序员身上使用非常的广泛,在编程中是大家高效的选择. PHP能实现的功能 1.可以 ...
- FPGA(4)晶振与计数器 -- 实现定时器(led定时闪烁、蜂鸣器频率控制(单响)、蜂鸣器报警(频带控制,多响))
目录 一.FPGA的晶振与定时器 二.定时器(led闪烁.蜂鸣器频率控制) 1.时钟上升沿.复位下降沿触发 2.复位,计数器清零 3.计数满1s时,计数器清零 4-1.led闪烁(每秒) 4-2.蜂鸣 ...
最新文章
- 进制转换converse
- 82年 AI程序员征婚启示火了!年薪百万,女生神回复
- 本科生顶刊发封面文章!他,是能成就导师的学生
- 计算机专业在线家教,基于SSM框架的家教平台设计与实现计算机专业.doc-原创力文档...
- Python的regex模块——更强大的正则表达式引擎
- 基于.Net Remoting的项目总结报告
- Java中的全局变量和局部变量——简单区别
- session每次请求都是新建的吗_每次去火车站都是提心吊胆,感觉就像进了贼窝一样,有同感的吗?...
- java httpclient post 上传文件_httpclient通过post multipart/form-data 上传文件
- 关于Android studio3.0的坑之butterknife 8.4.0
- 从Var Tick角度来对CE电源管理
- PHP 将微信录音arm格式文件转mp3格式
- 替代传统C/S和B/S技术的下一代客户/服务器编程技术
- Dollars即时聊天客户端应用源码
- 关于 Window 的 UWP 应用本地回环限制以及限制解除方案
- U盘启动盘 U盘安装Win10系统图文教程
- 太强!拿下腾讯公司技术突破奖,腾讯云 RTC 实时音视频技术到底了有多牛?...
- webworker应用场景_聊聊webWorker
- composer 升级/降级安装包
- 没有 XXX 的手册页条目