c - 在 omap4460 上设置 gptimer1

标签 c assembly arm cortex-a8 omap

我正在 omap4460(cortex a9)上编写裸机代码(无操作系统),但我没有成功设置正确的 gptimer1。

这是我的代码(遵循 OMAP4460 TRM)

/* for forwarding pending interrupts from distributor to Cpu interfaces */
*(volatile unsigned int *)(GICD_BASE + GICD_CTLR ) |= 0x00000001;

/* signaling interrupt by the cpu interface to the connected processor*/
*(volatile unsigned int *)(GICC_BASE + GICC_CTLR ) |= 0x00000001;

/* position the timer1 handler */
irq_table_function[GPT1_IRQ] = timer1handler;

/* clocks timer1 block */
*(volatile unsigned int *)CM_WKUP_CLKSTCTRL |= 0x00000003;
*(volatile unsigned int *)CM_WKUP_GPTIMER1_CLKCTRL |= 0x01000000;
*(volatile unsigned int *)CM_WKUP_GPTIMER1_CLKCTRL |= 0x00000002;

/* enable GPTimer1 functional and interface blocks */
*(volatile unsigned int *)GPT1MS_TIOCP_CFG |= 0x00000300;

/* capture interrupt enable */
*(volatile unsigned int *)GPT_TIER |= 0x00000004;

/* enable autoreload */
*(volatile unsigned int *)GPT_TCLR |= 0x00000002;

/* prescaler equal to zero */
*(volatile unsigned int *)GPT_TCLR &= ~0x0000003C;

/* positive increment value */
*(volatile unsigned int *)GPT_TPIR = 232000;

/* negative increment value */
*(volatile int *)GPT_TNIR = -768000;

/* load value */
*(volatile unsigned int *)GPT_TLDR = 0xFFFFFFE0;

/* enable timer1 */
*(volatile unsigned int *)GPT_TIER |= 0x00000001;

当我运行代码时,我从不访问我的中断 vector 表,我的中断 vector 表设置正确,因为“svc 0”有效。

我什至没有看到定时器计数器在运行。

请知道我缺少什么? 罗尼。

最佳答案

您是否检查过定时器模块是否已通电并且定时器模块的时钟是否已启用?时钟源的选择是在电源、复位和时钟管理 (PRCM) 模块中进行的(TRM 第 3 章)。

如果您尚未启用电源并为 PRCM 模块中的定时器外设模块配置时钟源,则定时器将不会执行任何操作。

关于c - 在 omap4460 上设置 gptimer1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22235017/

相关文章:

c++ - xorps 在同一个寄存器上的目的是什么?

c# - 比较和交换有什么用?

ARM 汇编中的凯撒解码器

linux - arm-linux-gnueabi-ld 和 fpc ppcrossarm 仍然链接到 linux-i386

c - 需要帮助从 Delphi 正确调用 C 函数

c - 有没有办法在循环中打印结构成员而无需在 C 中命名每个成员?

c - 标量集成

c - 在命令行上终止 C 程序,但确保编写器已完成编写

c - 非特权用户运行 C/asm 程序会对 Linux 造成什么危害?

arm - 如何在树莓派上安装 crystal-lang?