#include "NXP/iolpc2103.h"#include "config.h"#include <intrinsics.h>#include <stdio.h>/
#define TICK_PER_SEC 2#define Fosc 11059200 //晶振频率,10MHz~25MHz,应当与实际一至#define Fcclk (Fosc * 4) //系统频率,必须为Fosc的整数倍(1~32),且<=60MHZ#define Fcco (Fcclk * 4) //CCO频率,必须为Fcclk的2、4、8、16倍,范围为156MHz~320MHz#define Fpclk (Fcclk / 4) * 1 //VPB时钟频率,只能为(Fcclk / 4)的1 ~ 4倍
#define uint8 unsigned char#define int8 char#define uint32 unsigned int#define int32 int#define LEDCON1 (1<<17)#pragma vector=IRQV __irq __arm void irq_handler(void){ void (*interrupt_function)(); unsigned int vector; vector = VICVectAddr; //get Address interrupt_function = (void(*)())vector; if(interrupt_function!=NULL) { interrupt_function(); //调用中断指向函数 } else { VICVectAddr = 0; //清除在VIC中的中断 }}//----中断调用void Timer0Handler(void){ //clear interrupt flag T0IR_bit.MR0INT = 1; //change patern if((IOSET&LEDCON1)==0) IOSET = LEDCON1; else IOCLR = LEDCON1; VICVectAddr = 0; }//-----锁相环函数void PLL_Init(void){ //----interrupts initvoid Vic_Init(void){ //All interrupt changel to IRQ clear VICIntSelect = 0; //Disable all Interrupts VICIntEnClear = 0xFFFFFFFF; //clear all software interrupts; VICSoftIntClear = 0xFFFFFFFF; //register can be accessed int user or privileged mode VICProtection = 0; //Clear interrupt VICVectAddr = 0; //Clear address of the Interrupts Service routine (ISP) for non-vectored IRQS VICDefVectAddr = 0; //Clear address of the Interrupts Service routine (ISP) for vectored IRQS VICVectAddr0 = VICVectAddr1 = VICVectAddr2 = VICVectAddr3 =\ VICVectAddr4 = VICVectAddr5 = VICVectAddr6 = VICVectAddr7 =\ VICVectAddr8 = VICVectAddr9 = VICVectAddr10 = VICVectAddr11 =\ VICVectAddr12 = VICVectAddr13 = VICVectAddr14 = VICVectAddr15 =0; //Disable all vectored IRQ slots VICVectCntl0 = VICVectCntl1 = VICVectCntl2 = VICVectCntl3 =\ VICVectCntl4 = VICVectCntl5 = VICVectCntl6 = VICVectCntl7 =\ VICVectCntl8 = VICVectCntl9 = VICVectCntl10 = VICVectCntl11 =\ VICVectCntl12 = VICVectCntl13 = VICVectCntl14 = VICVectCntl15 =0;}//----GPIO Initvoid Gpio_Init(void){ PINSEL0 = 0x00000000; PINSEL1 = 0x00000000; SCS_bit.GPIO0M = 0; IODIR = LEDCON1; IOCLR = LEDCON1;}//----timer0//----使用中断方式写定时器,void Timer0_Init(void){ //cclk 44.2368M Fpclk 11.0592M //reset and stop timer0 T0TCR = 2; //计数器使能,复位 T0CTCR = 0; //每个PCLK的上升沿 使PC加 1 T0PR = 0; //预分频寄存器,不分频 PC 1 主要看的是TC 定时器计数器 //SET timer periord 11 0592Hz T0MR0 = Fpclk/TICK_PER_SEC;//定时1S //action T0MCR = 3; //中断,复位都允许 T0EMR = 0; //外部匹配寄存器 //Assign to IRQ VICIntSelect_bit.TIMER0 = 0; //set interrupt slots VICVectAddr0 = (uint32)Timer0Handler; VICVectCntl0_bit.NUMBER = VIC_TIMER0; VICVectCntl0_bit.ENABLED = 1; //timer0 interrupts enable VICIntEnable_bit.TIMER0 = 1; //Enable timer0 T0TCR = 1;}//----main()void main(void){ PLL_Init(); //memory map init flash __disable_interrupt(); Vic_Init(); //中断初始化 Gpio_Init(); //Io初始化 Timer0_Init(); //定时器 __enable_interrupt(); while(1) { };}
帮我看一下ARM的中断定时??不知道为什么一直在中断中,不能跳出?
答案:3 悬赏:40 手机版
解决时间 2021-05-02 02:21
- 提问者网友:浪荡绅士
- 2021-05-01 10:31
最佳答案
- 五星知识达人网友:笑迎怀羞
- 2021-05-01 11:41
你重发一遍吧。没办法看。。。。
全部回答
- 1楼网友:持酒劝斜阳
- 2021-05-01 13:33
太乱。。。。。。。
- 2楼网友:一叶十三刺
- 2021-05-01 12:59
乱啊 …………
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯