2014-03-06 10 views
2

omap4460 (cortex a9)에 베어 메탈 코드 (os 없음)를 쓰고 있는데 gptimer1을 올바르게 설정하지 못했습니다. omap4460에 gptimer1 설정

은 "SVC 0"이후,

/* 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; 

내가 코드를 실행하면, 내가 결코 내 인터럽트 벡터 테이블로 이동하지, 내 인터럽트 벡터 테이블이 올바르게 설정합니다 (OMAP4460 TRM에 따라) 내 코드입니다 공장.

나는 타이머 카운터가 작동하는 것을 보지 못합니다.

제가 누락 된 부분에 대해 알려주십시오. Rony.

답변

1

마침내 올바른 초기화 시퀀스를 얻을 수 있지만 내 코드를 다시 게시하는 것을 잊지 마십시오.

이것은, 내가 그것을

/* 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; 

감사합니다 도움이 될 희망, gptimer1를 초기화하는 방법

RONY

1

타이머 모듈에 전원이 공급되고 타이머 모듈의 시계가 활성화되었는지 확인 했습니까? 클록 소스의 선택은 PRCM (전원, 리셋 및 클록 관리) 모듈 (TRM의 3 장)에서 이루어진다.

전원을 사용하지 않고 PRCM 모듈의 타이머 주변 장치 블록에 클럭 소스를 구성한 경우 타이머는 아무 것도하지 않습니다.

+0

@Pipenbrinck이다 내가 내 대답을 참조 그에 따라 내 코드를 수정 – bonpiedlaroute