📄 main.c
字号:
#include "main.h"
extern void EnableInt (void);
extern U32 HandleTIMER0;
TIME_STRUC time = { 0x06,0x9,0x13,0x18,0x15,0x30,0x50};
TIME_STRUC time1;
/********************************************************************************************************
** 函数功能 :Timer0 中断服务函数
** 入口参数 :
** 出口参数 :
*********************************************************************************************************/
void __irq Rtc_Tick(void)
{
rI_ISPC=BIT_TICK;
uartprintf("\n\r\n\r Time is %x:%x:%x ",time1.hour,time1.min,time1.sec);
}
/********************************************************************************************************
** 函数功能 :TimeTick 中断设定
** 入口参数
** 出口参数 :无
*********************************************************************************************************/
void IntInit ( void )
{
//INT con
rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; //All=IRQ mode
pISR_TICK=(unsigned)Rtc_Tick;
rINTMSK=~(BIT_GLOBAL|BIT_TICK); //
EnableInt();
}
/********************************************************************************************************
** 函数功能 :长软件延时
** 入口参数 :dly 延时参数,值越大,延时越久
** 出口参数 :无
*********************************************************************************************************/
void DelayNS (U32 dly)
{
U32 i;
for ( ; dly>0; dly--)
for (i=0; i<10000; i++);
}
/********************************************************************************************************
** 函数功能 :main
** 入口参数 :无
** 出口参数 :无
*********************************************************************************************************/
int main( )
{
U32 cnt=0;
// U8 data8;
ChangePllValue(88, 6, 1);
PortInit();
console_init(115200);
RtcInit(&time);
IntInit();
time1.hour = 0x13;
time1.min = 0x36;
time1.sec = 0x44;
RtcSetTime(&time1);
while(1)
{
// uartprintf("\n\r\n\r Thank you very much! cnt10 = %d", cnt++);
DelayNS(100);
RtcGetTime(&time1);
// uartprintf("\n\r\n\r Time is %x:%x:%x ",time1.hour,time1.min,time1.sec);
}
while(1)
{
//案件按下
if( ( rPDATC & KEY ) ==0 )
{
//light off
rPDATB &= ~LED;
}
else
{
//light on
rPDATB |= LED;
}
//delay
DelayNS(50);
}
for (cnt =0 ;cnt<0x3000 ;cnt++)
{
rUBRDIV0 = cnt;
DelayNS (1);
uartprintf("\n\r\n\r cnt = 0x%x", cnt);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -