임베디드 OS 개발 프로젝트 CH7

In CH7, I will examine the timer hadware and the interrupt related to this.

RealviewPB uses SP804 Timer and my goal is to implement "delay()" using it.

To use a new hardware, fisrt to do is making a register struct.




레지스터


  • timerxload register
    - This is a value used to reload to the counter at the next rising edge.

  • timerxvalue register
    - This register decreases starting from the value of the timerxload register and invokes interrupt when its value be 0.

  • Timercontrol register`
ypedef union TimerXControl_t
{
    uint32_t all;
    struct {
        uint32_t OneShot:1;     //0
        uint32_t TimerSize:1;   //1
        uint32_t TimerPre:2;    //3:2
        uint32_t Reserved0:1;   //4
        uint32_t IntEnable:1;   //5
        uint32_t TimerMode:1;   //6
        uint32_t TimerEn:1;     //7
        uint32_t Reserved1:24;  //31:8
    } bits;
} TimerXControl_t;
  • 	- b0 : default(wrapping mode)
    • b1 : Timer off after an interrupt
  • [1]: Timer size
    - b0 : 16 bits timer
    • b1 : 32 bits timer
  • [3:2] : TimePre
    - Timer interval
    • b00 : a clock
    • b01 : 16 clocks
    • b10 : 256 clocks
  • [5] : Interrupt Enable bit
    - b0 : disable
    • b1 : enable
  • [6] : Mode bit
    - b0 : free running
    • b1 : Periodic
  • [7] : enabla bit
    - b0 : timer disable
    • b1 : timer enable

좋은 웹페이지 즐겨찾기