这是赵春江老师博客上的程序,是定时器中断实验.我自己添加在工程上编译有问题. 去掉_irq编译才能通过,但是这显然不对.
错误类型见附件!
/*************************************************
Function name: 这是基础实验的一个模版
Parameter : 无
Description : 做基础实验,直接调用该模板即可
Return : 无
Argument : 无
Autor & date : Daniel
**************************************************/
#define GLOBAL_CLK 1
#define _ISR_STARTADDRESS 0x33ffff00
#define U32 unsigned int
//#define pISR_TIMER4 (*(unsigned *)(_ISR_STARTADDRESS_0x58))
#define rSRCPND (*(volatile unsigned *)0x4a000000)
#define rINTMSK (*(volatile unsigned *)0x4a000008)
#define rINTPND (*(volatile unsigned *)0x4a000010)
#define rGPBCON (*(volatile unsigned *)0x56000010)
#define rGPBDAT (*(volatile unsigned *)0x56000014)
#define rGPBUP (*(volatile unsigned *)0x56000018)
#define rTCFG0 (*(volatile unsigned *)0x51000000)
#define rTCFG1 (*(volatile unsigned *)0x51000004)
#define rTCON (*(volatile unsigned *)0x51000008)
#include <stdlib.h>
#include <string.h>
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"
#include "mmu.h"
#include "profile.h"
#include "memtest.h"
//#define rTCNTB4 (*(volatile unsigned *)0x5100003c)
static void _irq IRQ_Timer4_Handle(void);
void Main(void) //??????Main?
{
rGPBCON = 0x155555;
rGPBUP = 0x7ff;
rGPBDAT = 0x1e0;
rSRCPND=rSRCPND | (0x1<<14); //xie yi qing 0?
rINTPND = rINTPND |(0x1<<14);
rINTMSK = ~(0x1<<14);
rTCFG0 &=0xFFFF00FF;
rTCFG0 |=0xf900;
rTCFG1 &=~0xf0000;
rTCFG1 |=0x20000;
rTCNTB4=12500;
rTCON &=~0xF00000;
rTCON |=0x700000;
rTCON &=~0x200000; //???
pISR_TIMER4=(U32)IRQ_Timer4_Handle;
while(1)
{
;
}
}
static void _irq IRQ_Timer4_Handle(void)
{
static int count;
count++;
rSRCPND = rSRCPND | (0x1<<14);
rINTPND = rINTPND | (0x1<<14);
if(count %4==0)
rGPBDAT = ~0x1e0;
else if(count % 4==1)
rGPBDAT = 0x1e0;
}
[ 此帖被promise2013在2011-06-27 14:40重新编辑 ]