/**********************************************************************
filename: timer.c
designer:
date: 2009/07/29
***********************************************************************/
#include <stdio.h>
#include <csl.h>
#include <csl_timer.h>
#include <csl_irq.h>
#include <csl_emifb.h>
static TIMER_Handle hTimer0;
static TIMER_Handle hTimer1;
static TIMER_Handle hTimer2;
static Uint32 TimerEventId0;
static Uint32 TimerEventId1;
static Uint32 TimerEventId2;
static int cnt = 0;
Uint32 count;
Uint32 adder = 0;
Uint32 adder1 = 0;
Uint32 adder2 = 0;
Uint32 adder3 = 0;
Uint32 led_flag = 0;
volatile unsigned char* LED = (volatile unsigned char *) 0x60000010;
//Timer control register (CTL)
static Uint32 TimerControl =
TIMER_CTL_RMK
(
TIMER_CTL_SPND_EMUSTOP,
TIMER_CTL_INVINP_NO, // TINP inverter control(INVINP)
TIMER_CTL_CLKSRC_CPUOVR8, // Timer input clock source (CLKSRC)
TIMER_CTL_CP_PULSE, // Clock/pulse mode(CP)
TIMER_CTL_HLD_YES, // Hold(HLD)
TIMER_CTL_GO_NO, // Go bit(GO)-
// resets & starts timer counter
TIMER_CTL_PWID_ONE, // Pulse width(PWID)-
// used only in pulse mode
TIMER_CTL_DATOUT_0, // Data output (DATOUT)
TIMER_CTL_INVOUT_NO, // TOUT inverter control (INVOUT)
TIMER_CTL_FUNC_GPIO // Function of TOUT pin(FUNC)
);
static EMIFB_Config MyEmifbConfig =
{
EMIFB_GBLCTL_RMK
(
EMIFB_GBLCTL_EK2RATE_FULLCLK, //1 X EMIF input clock
EMIFB_GBLCTL_EK2HZ_CLK, //eclkout2 continue output during hold
EMIFB_GBLCTL_EK2EN_ENABLE, //eclkout2 enable output
EMIFB_GBLCTL_BRMODE_MRSTATUS, //bus request is memory access or refresh pending/in progress
EMIFB_GBLCTL_NOHOLD_ENABLE,
EMIFB_GBLCTL_EK1HZ_CLK, //eclkout1 continue output during hold
EMIFB_GBLCTL_EK1EN_ENABLE //eclkout1 enable output
),
0x1120c301,
0x22a28a22,
0x22a28a22,
0x22a28a22,
EMIFB_SDCTL_DEFAULT,
EMIFB_SDTIM_DEFAULT,
EMIFB_SDEXT_DEFAULT,
0x00000002,
0x00000002,
0x00000002,
0x00000002
};
void main(void);
void TimerEventHandler(void);
extern far void vectors();
void main(void)
{
TIMER_Config myTimConfig;
//Initialise CSL
CSL_init();
//主浬EMIFB
EMIFB_config(&MyEmifbConfig);
//Open TIMER1 device, and reset it to power-on default state
hTimer0 = TIMER_open(TIMER_DEV0, TIMER_OPEN_RESET);
hTimer1 = TIMER_open(TIMER_DEV1, TIMER_OPEN_RESET);
hTimer2 = TIMER_open(TIMER_DEV2, TIMER_OPEN_RESET);
// hTimer2 = TIMER_open(TIMER_DEV2, TIMER_OPEN_RESET);
//Obtain the event ID for the timer device
TimerEventId0 = TIMER_getEventId(hTimer0);
TimerEventId1 = TIMER_getEventId(hTimer1);
TimerEventId2 = TIMER_getEventId(hTimer2);
//Point to the IRQ vector table
IRQ_setVecs(vectors);
//Enable NMI interrupt
IRQ_nmiEnable();
//Map TIMER events to physical interrupt number
IRQ_map(TimerEventId1, 14);
IRQ_map(TimerEventId0,13);
IRQ_map(TimerEventId2,15);
//Reset the timer events
IRQ_reset(TimerEventId1);
IRQ_reset(TimerEventId0);
IRQ_reset(TimerEventId2);
//---------Configure the timer devices---------
//Start count value at zero
myTimConfig.cnt = 0x0;
//Use predefined control value */
myTimConfig.ctl = TimerControl;
//Set period
myTimConfig.prd = 125000000;
TIMER_config(hTimer1, &myTimConfig);
TIMER_config(hTimer0, &myTimConfig);
TIMER_config(hTimer2, &myTimConfig);
//Enable the timer events(events are disabled while resetting)
IRQ_enable(TimerEventId0);
IRQ_enable(TimerEventId1);
IRQ_enable(TimerEventId2);
//Start the timers
TIMER_start(hTimer0);
TIMER_start(hTimer1);
TIMER_start(hTimer2);
//Globally enable interrupts
IRQ_globalEnable();
//Waiting for interrupt
for(;;)
{
adder++;
}
}
void TimerEventHandler(void)
{
//Process timer event here
cnt++;
count = TIMER_getCount(hTimer0);
}
interrupt void c_int13(void)
{
// TimerEventHandler();
if(led_flag == 0)
{
*LED = 0x01;
led_flag = 1;
}
else
{
*LED = 0x02;
led_flag = 0;
}
adder1++;
return;
}
interrupt void c_int14(void)
{
adder2++;
return;
}
interrupt void c_int15(void)
{
adder3++;
return;
}
没有合适的资源?快使用搜索试试~ 我知道了~
C6416_TIMER.rar_6416定时器_C6416_c6416 timer
共89个文件
h:62个
obj:3个
asm:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 41 浏览量
2022-09-21
17:36:33
上传
评论
收藏 352KB RAR 举报
温馨提示
本程序实现C6416开发板的定时器TIMER处理,主要包括定时器的设置及其操作!
资源推荐
资源详情
资源评论
收起资源包目录
C6416_TIMER.rar (89个子文件)
TIMER
C641X.H 11KB
TIMER.C 4KB
boot.asm 2KB
timer1.cmd 607B
Debug.lkv 428B
csl_dat_.sa 45KB
TIMER.CS_
SYMBOL.DBF 152KB
FILE.CDX 3KB
FILE.FPT 1007B
FILE.DBF 732B
SYMBOL.FPT 295KB
SYMBOL.CDX 170KB
DEC6416.gel 4KB
include
csl_stdinchal.h 4KB
csl_atl.h 4KB
csl_pci.h 13KB
csl_i2c.h 16KB
csl_legacyhal.h 396KB
csl_pcihal.h 39KB
csl_dma.h 14KB
csl_emuhal.h 8KB
csl_irqhal.h 9KB
csl_vcp.h 12KB
csl_hpihal.h 9KB
csl_tcphal.h 35KB
csl_pll.h 11KB
csl_emifahal.h 32KB
csl_pwrhal.h 6KB
csl_gpio.h 14KB
csl_vcphal.h 27KB
csl_tcp.h 21KB
csl_chip.h 7KB
csl_vphal.h 334KB
csl_mcasphal.h 271KB
csl_timer.h 8KB
csl_vp.h 29KB
csl_mcbsphal.h 79KB
csl_emifb.h 7KB
csl_dat_.sa 45KB
csl_dat.h 5KB
csl_utophal.h 17KB
csl_hpi.h 5KB
csl_timerhal.h 16KB
csl_mdio.h 6KB
csl_emu.h 3KB
csl_emifbhal.h 30KB
csl_emac.h 28KB
csl_pwr.h 4KB
csl_stdinc.h 2KB
csl_mdiohal.h 19KB
csl_atlhal.h 8KB
csl_mcasp.h 55KB
csl_emifhal.h 30KB
csl_chiphal.inc 8KB
csl_vic.h 4KB
csl_xbus.h 6KB
csl_chiphal.h 84KB
csl_dmahal.h 45KB
csl_i2chal.h 64KB
csl.h 5KB
csl_gpiohal.h 34KB
csl_pllhal.h 22KB
csl_xbushal.h 15KB
csl_gpioleg.h 1KB
csl_legacy.h 30KB
csl_cache.h 14KB
csl_mcbsp.h 16KB
csl_utop.h 8KB
csl_irq.h 12KB
csl_vichal.h 7KB
csl_edmahal.h 65KB
csl_emif.h 6KB
csl_emifa.h 7KB
csl_emachal.h 94KB
csl_edma.h 25KB
csl_cachehal.h 74KB
Debug.lkf 586B
csl_chiphal.inc 8KB
TIMER.pjt 1KB
TIMER.sbl 3KB
TIMER.paf2 4KB
vecs_timer1.asm 3KB
TIMER.paf 3KB
Debug
TIMER.map 9KB
boot.obj 1KB
TIMER.obj 14KB
vecs_timer1.obj 3KB
TIMER.out 32KB
cc_build_Debug.log 820B
共 89 条
- 1
资源评论
- liushenxue2023-06-10感谢资源主的分享,这个资源对我来说很有用,内容描述详尽,值得借鉴。
四散
- 粉丝: 49
- 资源: 1万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功