Timer Library

The mikroC PRO for AVR includes Timer library for easier handling of the internal Timer module of XMEGA devices.

Library Routines

Timer_Init

Prototype

unsigned long Timer_Init(char *module, unsigned long time);

Returns

Number of uS which is set.

Description

Initializes the Timer/Counter (TC) module.

Parameters :

  • module: address of the desired desired TC module :

    Value Description
    TCC0 TC module 0 on PORTC.
    TCC1 TC module 1 on PORTC.
    TCD0 TC module 0 on PORTD.
    TCD1 TC module 1 on PORTD.
    TCE0 TC module 0 on PORTE.
    TCE1 TC module 1 on PORTE.
    TCF0 TC module 0 on PORTF.
    TCF1 TC module 1 on PORTF.

  • time: Time interval in uS.
Requires

This routine is avaliable only for XMEGA devices.

Example
unsigned long time;

time = Timer_Init(&TCC0, 1000);

Timer_Interrupt_Enable

Prototype

void Timer_Interrupt_Enable(char *module);

Description

Enables TC overflow interrupt.

Parameters :

  • module: address of the desired desired TC module :

    Value Description
    TCC0 TC module 0 on PORTC.
    TCC1 TC module 1 on PORTC.
    TCD0 TC module 0 on PORTD.
    TCD1 TC module 1 on PORTD.
    TCE0 TC module 0 on PORTE.
    TCE1 TC module 1 on PORTE.
    TCF0 TC module 0 on PORTF.
    TCF1 TC module 1 on PORTF.

Requires

This routine is avaliable only for XMEGA devices.

Example
Timer_Interrupt_Enable(&TCC0);

Timer_Interrupt_Disable

Prototype

void Timer_Interrupt_Disable(char *module);

Description

Disables TC overflow interrupt.

Parameters :

  • module: address of the desired desired TC module :

    Value Description
    TCC0 TC module 0 on PORTC.
    TCC1 TC module 1 on PORTC.
    TCD0 TC module 0 on PORTD.
    TCD1 TC module 1 on PORTD.
    TCE0 TC module 0 on PORTE.
    TCE1 TC module 1 on PORTE.
    TCF0 TC module 0 on PORTF.
    TCF1 TC module 1 on PORTF.

Requires

This routine is avaliable only for XMEGA devices.

Example
Timer_Interrupt_Disable(&TCC0);
Copyright (c) 2002-2017 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code