首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在gptimer1上设置omap4460

在gptimer1上设置omap4460
EN

Stack Overflow用户
提问于 2014-03-06 20:17:40
回答 2查看 200关注 0票数 2

我正在omap4460 (皮质a9)上编写裸金属代码( not ),并且没有成功地设置正确的gptimer1。

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

代码语言:javascript
复制
/* 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;

当我运行代码时,我永远不会进入中断向量表,我的中断向量表是正确设置的,因为"svc 0“工作。

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

你知道吗,我错过了什么?罗尼。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-03-13 08:36:01

我终于得到了正确的初始化序列,但忘记回发我的代码。

这就是我初始化gptimer1的方式,希望它能有所帮助。

代码语言:javascript
复制
/* 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;

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

    /* set the priority of the interrupt */
    *(volatile unsigned int *)(GICD_BASE + GICD_IPRIORITYR_IRQ37 ) |= 0x00000200;
    /* set enable bit of IRQ37 */
    *(volatile unsigned int *)(GICD_BASE + GICD_ISENABLER37) |= 0x00000002;

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

    /* interrupt priority mask */
    *(volatile unsigned int *)(GICC_BASE + GICC_PMR ) = 0x00000080;

    /* forward the interrupt only to the processor which request the interrupt */
    *(volatile unsigned int *)(GICD_BASE + GICD_SGIR) |= 0x02000000;

    /* software reset */
    *(volatile unsigned int *)GPT1MS_TIOCP_CFG |= 0x00000002;

    /* RESET & Power settings*/
    /* wait until reset release */
    while( (*(volatile unsigned int *)GPT_TISTAT & 0x00000001) == 0)
        waitingtime++;
    /*GPT1MS_TIOCP_CFG [0]AUTOIDLE =0x0 : L4 clock free-running*/
    *(volatile unsigned int *)GPT1MS_TIOCP_CFG &= ~(0x1 << 0);
    /* idle mode equals to no-idle mode */
    *(volatile unsigned int *)GPT1MS_TIOCP_CFG |= 0x00000008;
    /*Functional clock is maintained during wake-up period */
    *(volatile unsigned int *)GPT1MS_TIOCP_CFG |= 0x00000300;
    /*NO Wake-up line assertion GPT1MS_TIOCP_CFG[2]ENAWAKEUP=0x0*/
    *(volatile unsigned int *)GPT1MS_TIOCP_CFG &= ~(0x1 << 2) ;
    /*GPT1MS_TIOCP_CFG [5]EMUFREE =0x1 : Timer counter free running in emulation*/
    *(volatile unsigned int *)GPT1MS_TIOCP_CFG |= (0x1 << 5);

    /* Enable wake-up interrupt events */
    *(volatile unsigned int *)GPT_TWER |= 0x00000007;
    /* Posted mode active */
    *(volatile unsigned int *)GPT_TSICR |= 0x00000004;
    /* enable autoreload */
    *(volatile unsigned int *)GPT_TCLR |= 0x00000002;

    /* set prescale clock timer value (PTV) to 1 */
    /* set PREscaler =128
and thus FCLK=38.4 MHz / 128 = 300 KHz << OCPCLK=38.4 / 4 = 9.6 MHz */
    *(volatile unsigned int *)GPT_TCLR |= 0x00000018;
    /* enable prescaler */
    *(volatile unsigned int *)GPT_TCLR |= 0x00000020;
    /* Overflow interrupt enable */
    *(volatile unsigned int *)GPT_TIER |= 0x00000007;

    /* Load timer counter value */
    *(volatile unsigned int *)GPT_TCRR = 0xFD000000;

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


    *(volatile unsigned int *)GPT_TPIR = 232000;
    /* negative increment value */
    *(volatile int *)GPT_TNIR = 0xFFF44800;

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

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

诚挚的问候,

罗尼

票数 1
EN

Stack Overflow用户

发布于 2014-03-12 08:27:45

您是否检查过计时器模块是否已启动,是否已启用到定时器模块的时钟?时钟源的选择由电源、复位和时钟管理(PRCM)模块进行(TRM第三章)。

如果您还没有启用电源,并且在PRCM模块中为您的计时器外围块配置了时钟源,则计时器将什么也不做。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22235017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档