我正在 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/