Skip to content
Ryan Summers edited this page Sep 5, 2015 · 32 revisions

This page documentation on the use of Timer Functions within SUBLIBinal.

Please Refer to the links below to the relevant information.

Functions available:

Structures

Timer_Config

Definition:

    typedef struct TIMER_CONFIG {
        Timer_Type which_timer; 
        uint frequency;
        uint pbclk;
        void (*callback); 
        boolean enabled; 
    }Timer_Config; 

The Timer_Config structure accepts 5 different parameters.

top

Enumerations

Timer_Type

typedef enum {
    Timer_1,
    Timer_2,
    Timer_3,
    Timer_4,
    Timer_5
} Timer_Type;

The timer type parameter is simply used to determine which timer in the microcontroller the library should configure.

top

Clock_Divider

typedef enum {
    Div_1,
    Div_2,
    Div_4,
    Div_8,
    Div_16,
    Div_32,
    Div_64,
    Div_256
} Clock_Divider;

The Clock_Divider enumeration is a specification of clock dividers to use. This parameter is only used if you are trying to manually override the clock divider and period registers. Please note, if you are modifying the divider of Timer_1, only Div_1, Div_8, Div_64, and Div_256 are available for use. If you attempt to use another divider, it will be automatically upgraded to the closest available divider. For example, if you attempt to update to Div_2, the divider will be set to Div_8 instead. This is only true for Timer_1.

top

Functions

initialize_Timer

Prototype
void initialize_Timer(Timer_Config config);

Parameters:

  • config: config is a Timer_Config structure that has been filled out with all relevant parameters. All parameters should be filled out with the exception of the callback function, which is optional.

top

disable_Timer

Prototype
void disable_Timer(Timer_Config config);

Parameters:

  • config: config is a Timer_Config structure that has been filled out. The only parameter that must strictly be filled out for this function is the which_timer parameter so that the function can properly disable the correct timer.

top

enable_Timer

Prototype
void enable_Timer(Timer_Config config);

Parameters:

  • config: config is a Timer_Config structure that has been filled out. The only parameter that must strictly be filled out for this function is the which_timer parameter so that the function can properly disable the correct timer.

top

update_period_Timer

Prototype
void update_period_Timer(Timer_Config config, int period);

Parameters:

  • config:
  • period:

top

update_frequency_Timer

Prototype
void update_frequency_Timer(Timer_Config config, float frequency);

Parameters:

  • config:
  • frequency:

top

update_divider_Timer

Prototype:
void update+divider_Timer(Timer_Config config, Clock_Divider div);

Parameters:

  • config:
  • div:

top

Clone this wiki locally