⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
字号:
 /*****************************************************************************
 *	$Workfile:   timer.c  $
 *	$Revision:   1.0  $
 *	$Author:   WellsK  $
 *	$Date:   Sep 22 2002 11:00:16  $
 *
 *	Project: Timer/interrupt example
 *
 *	Description:
 *    Timer 1 is used to generate a periodic interrupt. On each interrupt, the
 *    value on the 7-segment display will be incremented. The demo will stop
 *    when any button (SW10 - SW17) on the EVB is pressed.
 *
 *    Be sure to define INTC_IRQ as a compiler define, or the interrupt
 *    driver will not generate entry/exit context code for the interrupt
 *    vector ISR.
 *
 *	Revision History:
 *	$Log:   //smaicnt2/pvcs/VM/CDROM/archives/KEV7A400/Software/Examples/timer/timer.c-arc  $
 * 
 *    Rev 1.0   Sep 22 2002 11:00:16   WellsK
 * Initial revision.
 * 
 * 
 *	COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 *		CAMAS, WA
 ****************************************************************************/

#include "SMA_types.h"
#include "LH7A400_EVB_CPLD_driver.h"
#include "LH7A400_timer_driver.h"
#include "SMA_sevenseg_driver.h"
#include "LH7A400_int_driver.h"

// Define the frequency in Hz for the interrupt here. Frequencies over 10Hz
// may be hard to distinguish on the 7-segment display.
#define TICKS_SEC 3

void timer_isr (void)
{
    static INT_32 val = 0;

    val++;
    util_set_sevenseg_hexval (val, 0);
    
    // The timer interrupt must be cleared, or interrupts will keep going
    timer_int_clear (TIMER1);
}

int main (void)
{
    volatile UNS_8 pb;
    INT_32 i;

    // Initialize timer 1
    timer_init (TIMER1);

    // Set timer 1 for a (TICKS_SEC)Hz interrupt rate
    timer_clock_2k (TIMER1);
    timer_periodic (TIMER1);
    timer_set_counts (TIMER1, (2000 / TICKS_SEC));

    // Attach the interrupt
    timer_irq_setup (TIMER1, 8, timer_isr);
    timer_int_enable (TIMER1);

    // Enable IRQ interrupts
    enable_IRQ ();                           

    // Start the timer
    timer_start (TIMER1);

    // Wait for depress first
    pb = LH7A400_pld_get_pb ();
    while (pb == 0)
    {
        // This small loop prevents the bus from getting hammered
        for (i = 0; i < 1000; i++);

        pb = LH7A400_pld_get_pb ();
    }

    // Stop timer and disable IRQ interrupts
    timer_stop (TIMER1);
    disable_IRQ ();                           

    return 1;
 }
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -