📄 tsblink.c
字号:
//*********************************************************
//
// tsblink.c : Simple example of flag toggling on the
// TigerSharc to blink LEDs. The processor
// LEDs blink as follows:
// PROC RATE
// P0 1Hz
// P1 2Hz
// P2 4Hz
// P3 8Hz
//
// PROVIDED BY:
// ------------
// Bittware, Inc.
// 33 North Main Street
// Concord, NH 03301
// Ph: 603-226-0404
// Fax: 603-226-6667
// WWW: www.bittware.com
// E-mail: support@bittware.com
//
// Copyright (c) 2001
//
// Ver. Dates Author Changes
// ---- -------- ------ -----------------------------
// 1.0 11/29/01 rpc Creation
//*********************************************************
#include <defts101.h>
#include <sysreg.h>
#include <signal.h>
#include "utils.h"
/**********************************************************/
#define USE_INTERRUPT 1 // Set to 1 to use the timer interrupt
int count, cnt;
int mpid;
volatile int intr_count = 0;
/**********************************************************/
/* */
/* */
/* */
/**********************************************************/
void timer0_handler(int sig)
{
toggle_leds(FLG2|FLG3);
intr_count++;
}
/**********************************************************/
/* */
/* */
/* */
/**********************************************************/
void main ( void )
{
int tmr_val;
// Set up SYSCON and SDRAM
init_Tiger();
// Initialize flags
prep_leds();
mpid = GetIDC();
#if USE_INTERRUPT
// Set up timer interrupts
interrupt(SIGTIMER0LP, timer0_handler); // attach handler for timer0 interrupt
tmr_val = 240000000 >> mpid; // timer value dependent upon processor
init_timer(0, 0, tmr_val);
start_timer(0);
#endif
// Toggle flags to blink LEDs
while(1)
{
count++;
// count++;
// count++;
// count++;
//#if !USE_INTERRUPT
// for (cnt = 0 ; cnt < 24000000 ; cnt++); // delay
// if(count % 2)
__builtin_sysreg_write(__SQCTLST, (FLG2|FLG3)); // set the flag bits
// else
// __builtin_sysreg_write(__SQCTLCL, ~(FLG2|FLG3)); //clear the flag bits
//#endif
}
}
/**********************************************************/
/* End of file tsblink.c */
/**********************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -