#include "stdio.h"
#include "stdlib.h"
#include "configure.h"
#include "register_system.h"
#include "register_cpu.h"
#define TCR0 *((ioport volatile unsigned*)0x1810)
#define TIM0PRD1 *((ioport volatile unsigned*)0x1812)
#define TIM0PRD2 *((ioport volatile unsigned*)0x1813)
#define TIM0CNT1 *((ioport volatile unsigned*)0x1814)
#define TIM0CNT2 *((ioport volatile unsigned*)0x1815)
#define TIM0IER *((ioport volatile unsigned*)0x1816)
#define TIAFR *((ioport volatile unsigned*)0x1c14)
#define PCGCR1 *(volatile ioport Uint16*)(0x1c02)
#define PCGCR2 *(volatile ioport Uint16*)(0x1c03)
void PLL_100MHZ( );
void main( void )
{
/* Enable clocks to all peripherals */
PCGCR1=0;
PCGCR2=0;
/* set PLL to 100MHz */
PLL_100MHZ( );
/* TIM0 EN | AutoReload enable | Prescale = 0(100/2 = 50MHz) ==> 20nsec */
TCR0=0x8002;
/* 500msec/20ns = 25000000 (0x017d7840) */
TIM0PRD1 = 0x7840;
TIM0PRD2 = 0x017d;
TIM0CNT1 = 0x0000;
TIM0CNT2 = 0x0000;
/* clear all previous timer interrupts */
TIAFR = 0x0007;
IER0 = 0x0010; /* enable timer int */
asm(" BCLR INTM"); /* enable gloable interrupt */
TCR0 |= 0x0001; /* start timer0 */
while(1);
}
int on=0;
interrupt void Timer_isr(void)
{
TIAFR |=0x0001;
if(on==0){
on=1;
asm(" bset XF"); /* light on */
}else{
on=0;
asm(" bclr XF"); /* light off */
}
}
朋友们帮我看看定时器中断服务程序哪里有问题好吗? |