Timer Library

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

Library Routines

Timer_Init

Prototype

sub function Timer_Init(dim byref module as byte, dim time as longword) as longword

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
dim time as longword

time = Timer_Init(TCC0, 1000)

Timer_Interrupt_Enable

Prototype

sub procedure Timer_Interrupt_Enable(dim byref module as byte)

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

sub procedure Timer_Interrupt_Disable(dim byref module as byte)

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-2012 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