init.c

来自「blackfin531处理器实时时钟程序,一秒一秒走,适用于初学者学习硬件bla」· C语言 代码 · 共 55 行

C
55
字号
#include <cdefBF532.h>
#include <sys\exception.h>     //contain interrupt_kind enumeration 


EX_INTERRUPT_HANDLER(RTC_ISR);


void Init_RTC(void)
{
    *pRTC_ICTL = 0x4;
    *pRTC_PREN = 0x1;
    
//   int current_time = *pRTC_STAT;
//   printD("time is %x", current_time);
   
}



void Init_Interrupts(void)
{
    *pSIC_IAR0 = 0x1fffffff;
	*pSIC_IAR1 = 0xffffffff;
	*pSIC_IAR2 = 0xffffffff;					// RTC

	// assign ISRs to interrupt vectors
	register_handler(ik_ivg8, RTC_ISR);		// RTC ISR -> IVG 8

	// enable RTC interrupt
	*pSIC_IMASK = 0x00000080;

}



EX_INTERRUPT_HANDLER(RTC_ISR)
{

	// confirm interrupt handling
	*pRTC_ISTAT = 0x0004;
	
	int sec,min,hor,day,time;

	time = *pRTC_STAT;
	
	sec = time & 0x3f;
	min = (time>>6) & 0x3f;
	hor = (time>>12) & 0x1f;
	day = (time>>17) & 0x7fff;
	
	printD("\nTime is %d:%d:%d:%d\n",day,hor,min,sec);


}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?