سلام.من ئاحذ rtc میکو م رو راه اندازی کردم و درست کار میکنه.ولی برای ثانیه شمار اینتراپت گذاشتم و توی اینتراپت یه فلگ رو یدونه اضافه میکنم.ولی نمیدونم چرا بعد اومدن اینتراپت فلگم دوتا اضافه میشه.کسی میدونه چرا؟
#include <LPC17xx.h>
#include "lcd.h"
int flg;
char buf[16];
/************************************************** ****************************
Real Time Clock Interrupt service function
************************************************** ****************************/
void RTC_IRQHandler(void) {
/* write code here */
flg++;
/* list of all available flags, select which to use */
LPC_RTC->ILR = (1UL<<0); /* Clear RTC counter increment interrupt flag */
LPC_RTC->ILR = (1UL<<1); /* Clear RTC alarm interrupt flag */
}
int main(void)
{
int f;
lcd_init();
LPC_SC->PCONP = (LPC_SC->PCONP & 0xEFEFF7DE) | (1UL<<15); /* Enable peripheral clock for IOCON, GPIO, GPIO interrupts (default is enabled) */
LPC_SC->PCONP |=(1<<9);
LPC_PINCON->PINSEL0 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */
LPC_PINCON->PINMODE0 = 0x00002AAA; /* binary: 00000000_00000000_00101010_10101010 */
LPC_GPIO0->FIODIR = 0x0000007F; /* binary: 00000000_00000000_00000000_01111111 */
LPC_PINCON->PINMODE_OD0 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */
/************************************************** ****************************
Vectored Interrupt initialization
************************************************** ****************************/
NVIC_SetPriority(RTC_IRQn,0); /* Default priority group 0, can be 0(highest) - 31(lowest) */
NVIC_EnableIRQ(RTC_IRQn); /* Enable Real Time Clock Interrupt */
LPC_RTC->CCR=1<<1|1<<4;
LPC_RTC->CALIBRATION = 0x00;
LPC_RTC->DOM = 0; // Update date value
LPC_RTC->MONTH = 0; // Update month value
LPC_RTC->YEAR = 0; // Update year value
LPC_RTC->HOUR = 0; // Update hour value
LPC_RTC->MIN = 0; // Update min value
LPC_RTC->SEC = 0; // Update sec value
LPC_RTC->CIIR=0x1;
LPC_RTC->AMR=0xFF;
LPC_RTC->CCR=1;
lcd_clear();
delay_ms(100);
flg=0;
while(1)
{
lcd_gotoxy(0,0);
sprintf(buf,"flg=%d",flg);
lcd_print(buf);
}
}
- - - Updated - - -
کدم کپی کردم این علامتاش بهم ریخت.:|