/* example code for tbu ST72F62 device */

#include "ST7lib_config.h"                             /*Configuration File*/
#define TBU_Standalone

void TBU_IT_Routine(void);
void main(void);

void main (void)
{    
    unsigned char Counter_Value8 = 224;
    unsigned int Counter_Value16 = 10330;
    unsigned char counter;                             /*Variable declaration*/
    
    EnableInterrupts                               /*Reset the interrupt mask*/
/*----------------------------------------------------------------------------
For Stand alone mode
-----------------------------------------------------------------------------*/    
#ifdef TBU_Standalone                               /*Selects Standalone mode*/

    TBU_Init (TBU_DEFAULT+TBU_IT_ENABLE);         /*Enable overflow interrupt*/ 
    TBU_SetPrescCount8(TBU_Prescvalue_256,Counter_Value8); /*Generates Interrupt 
                                                                    after 1ms*/
    counter = TBU_ReadCounter();                 /*Reads the value of counter*/

/*------------------------------------------------------------------------------
For Cascade Mode
------------------------------------------------------------------------------*/
#else
#ifdef TBU_Cascade                                      /*Selects Cascade mode*/

    TBU_Init (TBU_IT_ENABLE+TBU_ART_CASCADE);                              
                                    /*Enable interrupt and select Cascade mode*/
    TBU_SetPrescCount16(TBU_CasPrescvalue_128,Counter_Value16);                          
                                       /*Generate an interrupt after 1 second */
#endif  
#endif
    TBU_Enable();                                     /*Enable the TBU counter*/     
    while(1);  
}

/***********************************Interrupt Subroutine************************/ 

#ifdef _HIWARE_                                    /* test for HIWARE Compiler */
#pragma TRAP_PROC SAVE_REGS              /* Additional registers will be saved */
#else
#ifdef _COSMIC_                                    /* Test for Cosmic Compiler */
@interrupt                                        /* Cosmic interrupt handling */
#else
#error"Unsupported Compiler!"                   /* Compiler Defines not found! */
#endif
#endif

void TBU_IT_Routine(void)
{ 
    TBU_ClearOverflow();                   /*Clears the Overflow flag*/
}


/**********************************Program stop*********************************/


















