본문 바로가기

[TI]/TM4C

TM4C123 - Timer 테스트

TM4C123  - Timer 테스트



TM4C123의 페리는 정말 막강한데12개의 타이머와 20개의 PWM을 출력 할 수 있다. 그리고 마음에 드는 사항이 64bit 타이머가 6개 있다.


TM4C123의 타이머 관련 특징

■ 16/32-bit operating modes:

-16- or 32-bit programmable one-shot timer

-16- or 32-bit programmable periodic timer

-16-bit general-purpose timer with an 8-bit prescaler

-32-bit Real-Time Clock (RTC) when using an external 32.768-KHz clock as the input

-16-bit input-edge count- or time-capture modes with an 8-bit prescaler

-16-bit PWM mode with an 8-bit prescaler and software-programmable output inversion of the PWM signal


■ 32/64-bit operating modes:

-32- or 64-bit programmable one-shot timer

-32- or 64-bit programmable periodic timer

-32-bit general-purpose timer with a 16-bit prescaler

-64-bit Real-Time Clock (RTC) when using an external 32.768-KHz clock as the input

-32-bit input-edge count- or time-capture modes with a16-bit prescaler

-32-bit PWM mode with a 16-bit prescaler and software-programmable output inversion of the PWM signal


■ Count up or down


■ Twelve 16/32-bit Capture Compare PWM pins (CCP)



TM4C123의 타이머 블록도




TM4C123 타이머 CCP 핀맵




TM4C123 타이머 초기화 함수

void InitTimer0(void)

{

    // Enable the peripherals used by this example.

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);


    // Enable processor interrupts.

    ROM_IntMasterEnable();


    // Configure the two 32-bit periodic timers.

    ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);

    

    //1ms

    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet()/1000);


    

    // Setup the interrupts for the timer timeouts.

    ROM_IntEnable(INT_TIMER0A);

    ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);


    // Enable the timers.

    ROM_TimerEnable(TIMER0_BASE, TIMER_A);    

}




TM4C123 타이머 인터럽트 핸들러

void Timer0IntHandler(void)

{

    // Clear the timer interrupt.

    ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);


    gTimeTick1++;    

}




TM4C123 타이머 예제 소스코드

int main(void)

{

    int cnt = 0;

    

    SystemInit();

    Led1Init();

    Led1On();

    

    Led2Init();

    Led2On();

    

    DebugInit(BAUD_115200);

    DebugPrint("TM4C123 Timer Test\r\n");

    

    InitTimer0();

    

    while(1)

    {

        if(gTimeTick1>1000)

        {

            gTimeTick1 = 0;

            Led1Toggle();

        }

    }


}


반응형