18.3.1 Design Flow

Follow the steps described below to use Timer in an application.

  1. By default, the Timer module is enabled in the Libero project.
  2. Generate the component by clicking Generate Component or by selecting SmartDesign > Generate Component. For more information on generation of the component, see the latest SmartDesign user guide on Libero SoC User Documentation. The firmware driver folder and SoftConsole workspace is included in the project. Click the highlighted Configure firmware as shown in the following figure to find the Timer drivers.
    Figure 18-5. Timer Driver User Guide
  3. Click Generate Bitstream under Program Design to complete *.fdb file generation. Double click Export Firmware under Handoff Design for Firmware Development in the Libero SoC design flow window to generate the SoftConsole Firmware Project. The SoftConsole folder contains the mss_timer firmware driver. The firmware driver, mss_timer (mss_timer.h) which provides a set of functions for controlling the Timer, can also be downloaded from the Microchip firmware catalog. The following table lists the APIs for Timer.
  4. For more information on the APIs, see the SmartFusion2_MSS_Timer_Driver_UG (shown in the preceding figure).
    Table 18-3. MSS Timer APIs
    Category API Description and Usage
    Initialization functions MSS_TIM1_init() Initializes Timer1
    MSS_TIM2_init() Initializes Timer2
    MSS_TIM64_init() Initializes 64-bit Timer
    Control functions MSS_TIM1_load_immediate() Loads the value passed by the load_value parameter into the Timer1 down-counter.
    MSS_TIM1_load_background() Specify the value that will be reloaded into the Timer1 down-counter the next time the counter reaches zero.
    MSS_TIM1_get_current_value() Returns the current value of the Timer1 down-counter.
    MSS_TIM1_start() The MSS_TIM1_start() function enables Timer1
    MSS_TIM1_stop() The MSS_TIM1_stop() function disables Timer1
    MSS_TIM2_load_immediate() Loads the value passed by the load_value parameter into the Timer2 down-counter
    MSS_TIM2_load_background() Specify the value that will be reloaded into the Timer2 down-counter the next time the counter reaches zero.
    MSS_TIM2_get_current_value() Returns the current value of the Timer 2 
down-counter.
    MSS_TIM2_start() Enables Timer 2
    MSS_TIM2_stop() Disables Timer 2
    MSS_TIM64_load_immediate() Loads the values passed by the load_value_u and load_value_l parameters into the 64-bit timer down-counter
    MSS_TIM64_load_background() Specify the 64-bit value that will be reloaded into the 64-bit timer down-counter the next time the counter reaches zero
    MSS_TIM64_get_current_value() Read the current value of the 64-bit timer 
down-counter.
    MSS_TIM64_start() Enables the 64-bit timer
    MSS_TIM64_stop() Disables the 64-bit timer
    Interrupt control functions MSS_TIM1_enable_irq() Enable interrupt generation for Timer 1
    MSS_TIM1_disable_irq() Disable interrupt generation for Timer 1
    MSS_TIM1_clear_irq() Clear a pending interrupt from Timer 1
    MSS_TIM2_enable_irq() Enable interrupt generation for Timer 2
    MSS_TIM2_disable_irq() Disable interrupt generation for Timer 2
    MSS_TIM2_clear_irq() Clear a pending interrupt from Timer 2
    MSS_TIM64_enable_irq() Enable interrupt generation for the 64-bit timer
    MSS_TIM64_disable_irq() Disable interrupt generation for the 64-bit timer
    MSS_TIM64_clear_irq() Clear a pending interrupt from the 64-bit timer.
  5. For more information on Timer usage, the sample projects are available and can be generated, as shown in the following figure.
    Figure 18-6. Generating Sample Project