导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→发表看法:[zjh1112]关于定时器中断的问题



No.95894
作者:zjh1112
邮件:zjh1112.whu@tom.com
ID:57257
登陆:1次
文章数:2篇
最后登陆IP:202.114.85.91
最后登陆:2006/9/28 17:05:01
注册:2006/7/22 16:42:39
财富:107
发帖时间:2006/7/22 16:54:02
发贴者IP:61.183.148.130
标题:zjh1112:关于定时器中断的问题
摘要:No.95894关于定时器中断的问题 各位高手大家好,目前我在基于ARM7和UCOS—ii做一个定时的应用程序,因TIMER0已被操作系统利用,故我的定时是利用TIMER1来做的,以下是我在应用程序中的代码:
void Control_Task(void* pdata) 
{
 /*定时器的配置和开启*/
 
 for( ; ;)
 {
   unsigned char err;
   Uart_Printf("test timer\n");
  
   rTCNTB1 = 1000*8; //8*ms;  
   rTCMPB1 = 0x0;
   rTCON |= (0x1   <  < 9);           //manual update  
   rTCON |=  ((0x1   <  < 8) | (0x1   <  < 11)) + rTCON & ~(0x1   <  < 9);//start, auto-load mode
   rINTMSK&=(~BIT_GLOBAL);
   rINTMSK &= ~(BIT_TIMER1);
 
   Uart_Printf("complete config!\n");
   OSSemPend(comsem,0,&err); //等待中断延时的完成
   Uart_Printf("hello!\n");
 }
 
}
而另外中断服务程序在uhal.c中,其具体代码如下:
#include   <stdarg.h>  
#include   <string.h>  
#include   <stdio.h>  


#include "44breg.h"
#include "44blib.h"
#include "uhal.h"
#include "uart.h"
#include "def.h"
#include "includes.h"
#include "option.h"

#include "ne2kif.h"

extern OS_EVENT* comsem;
int count=0;

void do_irq(void);
extern void OSISR(void);
//extern void FISR(void);


__irq void do_firq(void)
{  while(1)
  Uart_Printf("!!!Enter FIRQ.");
 


__irq void Timer1(void)  //有关TIMER1的中断服务程序

 Uart_Printf(" enter Timer1\n");
 rTCON &= ~((0x1   <  < 8) | (0x1   <  < 11));//stop, one shot mode
 rINTMSK |= BIT_TIMER1;
 Uart_Printf(" enter Timer1\n");
// count++;
// if(count==10)
// {
//  count=0;
  OSSemPost(comsem);
// }
 
}
 
__irq void BreakPoint(void)
{ while(1)
 Uart_Printf("!!!Enter break point.\n"); 
 }//BreakPoint
 
__irq void OutDebug(unsigned int num)
{while(1)
 Uart_Printf("\r\n***STACK***:%d\r\n", num);

}//OutDebug

//Initialze interrupts.
void uHALr_InitInterrupts(void)
{
 // Non-vectored,IRQ disable,FIQ disable    
   // rINTCON=0x0;  
   rINTCON=0x5; 

 // All=IRQ mode
    rINTMOD=0x0;   

  
}//uHALr_InitInterrupts


//Initialize timer that is used OS.
void uHALr_InitTimers(void)
{
 rTCFG0= 0x00000000;               // prescaler0 = 0
 rTCFG1= 0x00000000;               // mux0 = 1/2   
    
rTCNTB0= MCLK/2/OS_TICKS_PER_SEC;

 rTCMPB0= 0x0;
 rTCON=0x2;  //update mode for TCNTB0 and TCMPB0.
 rTCON=0x9;  //timer0 = auto reload, start 
}//uHALr_InitTimers

int I_COUNT=0;

__irq void DebugUNDEF(void)
{ while(1)
 Uart_Printf("!!!Enter UNDEFINED.\n"); 

}//BreakPoint


__irq void DebugSWI(void)
{ //while(1)
 Uart_Printf("!!!Enter SWI.\n"); 

}

__irq void DebugABORT1(void)
{ while(1)
 Uart_Printf("!!!Enter PROGRAM ABORT\n"); 

}


__irq void DebugABORT2(void)
{ while(1)
 Uart_Printf("!!!Enter DATA ABORT\n"); 

}

void do_irq(void)
{
 U32 intpnd;  
 Uart_Printf("Total Interrupt Enter\n");
 intpnd = rINTPND & (~rINTMSK);
  
 while(intpnd)
 {
    
  if(intpnd & BIT_TIMER0)
  {  
   Uart_Printf("enter timer0!\n"); 
   OSTime ......

>>返回讨论的主题



  发表回复
用户名   *您没有注册?
密码   *
验证码   * .
标题   *
心情
随便说说    我回答你    最新发现    得意的笑   
气死我了    真是没劲    坚决同意    表示反对   
大家过来    好奇怪哟    懒得理它    大家小心   
文件上传
内容


字体:      字体大小:    颜色:
粗体 斜体 下划线 居中 超级连接 Email连接 图片 Flash图片 Shockwave文件 realplay视频文件 Media Player视频文件 QuickTime视频文件 引用 飞行字 移动字 发光字 阴影字 查看更多的心情图标 背景音乐
点击加入表情
                         
选项
有回复时用短消息通知您?

   




老古网执行:16毫秒 最大:2625毫秒 查询6次