file:///C:/Users/ChenQ/Documents/Tencent%20Files/418395300/Image/%60FV5(CL7JL%60Q]HIT0XWAT9X.jpg
#include <stdio.h>
#include "NUC1xx.h"
#include "DrvUART.h"
#include "DrvRTC.h"
#include "DrvGPIO.h"
#include "DrvSYS.h"
int32_t bLoop=TRUE;
void TickCallBackFun()
{
S_DRVRTC_TIME_DATA_T sCurTime;
DrvRTC_Read(DRVRTC_CURRENT_TIME,&sCurTime);
printf("\n%d/%02d/%02d %02d:%02d:%02d\n",sCurTime.u32Year,sCurTime.u32cMonth,sCurTime.u32cDay,sCurTime.u32cHour,sCurTime.u32cMinute,sCurTime.u32cSecond);
printf("\n");
}
void AlarmCallBackFun()
{
bLoop=FALSE;
printf("\nTime is OK\n");
}
int32_t main()
{
STR_UART_T sParam;
S_DRVRTC_TIME_DATA_T cTime;
S_DRVRTC_TIME_DATA_T sInitTime;
char a[] = " asdasdasd ";
UNLOCKREG();
SYSCLK->PWRCON.XTL12M_EN = 1;
DrvSYS_Delay(5000);
sParam.u32BaudRate=115200;
sParam.u8cDataBits = DRVUART_DATABITS_8;
sParam.u8cStopBits = DRVUART_STOPBITS_1;
sParam.u8cParity = DRVUART_PARITY_NONE;
sParam.u8cRxTriggerLevel = DRVUART_FIFO_1BYTES;
DrvGPIO_InitFunction(E_FUNC_UART0);
DrvSYS_SelectIPClockSource(E_SYS_UART_CLKSRC,0);
if(DrvUART_Open(UART_PORT0,&sParam) == E_SUCCESS)
{
printf("\n--------------Open UART0 sucess--------------\n");
SendChar(a);
DrvRTC_Init();
sInitTime.u32Year = 2010;
sInitTime.u32cMonth = 11;
sInitTime.u32cDay = 6;
sInitTime.u32cHour = 11;
sInitTime.u32cMinute = 35;
sInitTime.u32cSecond = 23;
sInitTime.u32cDayOfWeek = DRVRTC_MONDAY;
sInitTime.u8cClockDisplay = DRVRTC_CLOCK_24;
if(DrvRTC_Open (&sInitTime)!=E_SUCCESS)
{
printf("\n RTC Open is fail \n");
return FALSE;
}
printf("\nTime is:\n");
printf("\nPlease input 1 to set Clock\n");
DrvRTC_SetTickMode(DRVRTC_TICK_1_SEC);
DrvRTC_EnableInt(DRVRTC_TICK_INT,TickCallBackFun);
while(getchar()!='1');
DrvRTC_Read(DRVRTC_CURRENT_TIME,&cTime);
cTime.u32cSecond=cTime.u32cSecond+5;
DrvRTC_Write(DRVRTC_ALARM_TIME,&cTime);
DrvRTC_EnableInt(DRVRTC_ALARM_INT,AlarmCallBackFun);
printf("\nThe clock is open\n");
while(bLoop);
printf("\nSmple is over\n");
}
}
图为代码的结果。代码放在140的芯片上运行完全正常。放在100的芯片上就出现这个问题。请教下大家。怎么回事?
另.用while()持续发送printf 到一定量数据的时候,数据就会出错。 |