lpc1768 ile dijital-analog saat uygulaması

Başlatan yamak, 16 Eylül 2011, 19:16:30

yamak

LPC1768 in rtc si ile ilgili uygulama olması ve glcd ile analog saat uygulamasının içimde kalmasından dolayı böyle bir uygulama yaptım.Kullandığım kit mcb1700 dür.Saat ayarlamaları için kit üzerindeki joystick i kullandım,ayarlama kısmına geçmek için key1 e yaklaşık 2 sn basılı tutmak ayarlama kısmından çıkmak için de INT0 butonuna basmak yeterli. Umarım bu konu ile ilgilenen arkadaşlara yardımcı olmuşumdur.



main:

#include <lpc17xx.h>
#include <yusuf_rtc.h>
#include <yusuf_lpc17xx_delay.h>
#include <stdio.h>
#include <lpc_glcd.h>
#include <math.h>
#define pi 3.1415926535897932384626433832795
RTC_TIME local_time,current_time,alarm_time;
uint32_t sec,min,hour,mon,mday,wday,year,i=1,j=0,z=0,start_count,select=0,pwm;
volatile uint32_t start=0,stop=0,setting=0,alarm_on=1,yanson=0;
char f[10]=" ";
char g[10]=" ";
void pwm_init(void);
void clock_write(void);
void pwm_start(void);
void pwm_stop(void);
void SysTickStop(void);
void analog_saat(void)
{
	
char v[8]=" ";
	
int analog_hour,analog_min,analog_sec,akrep_aci,yelkovan_aci,akrep_x,akrep_y,yelkovan_x,yelkovan_y,saniye_aci,saniye_x,saniye_y,i;
	
//glcd_circle(30,30,28,0,1);
	
glcd_circle(95,30,28,0,1);
	
glcd_circle(95,30,2,1,1);
	
glcd_text57(91,5,"12",1,1);
	
glcd_text57(117,27,"3",1,1);
	
glcd_text57(93,50,"6",1,1);
	
glcd_text57(70,27,"9",1,1);
	
glcd_line(106,10,108,8,1);
	
glcd_line(114,19,116,17,1);
	
glcd_line(114,41,116,43,1);
	
glcd_line(106,49,108,51,1);
	
glcd_line(83,49,81,51,1);
	
glcd_line(75,41,73,43,1);
	
glcd_line(75,19,73,17,1);
	
glcd_line(84,10,82,8,1);
	
current_time=RTCGetTime();
	
analog_min=current_time.RTC_Min;
	
analog_hour=current_time.RTC_Hour;
	
analog_sec=current_time.RTC_Sec;
	
if(
analog_hour>11)
	
analog_hour=analog_hour-12;
	
if(
analog_hour>3)
	

	
	
analog_hour=15-analog_hour;
	
else
	
	
analog_hour=3-analog_hour;
	
if(
analog_min>15)
	
	
analog_min=75-analog_min;
	
else
	
	
analog_min=15-analog_min;
	
if(
analog_sec>15)
	
	
analog_sec=75-analog_sec;
	
else
	
	
analog_sec=15-analog_sec;
	
akrep_aci=analog_hour*30-(int)((current_time.RTC_Min/12)*6);
	
yelkovan_aci=analog_min*6;
	
saniye_aci=analog_sec*6;
	
akrep_x=(cos((pi*akrep_aci)/180))*15+95;
	
akrep_y=30-(sin((pi*akrep_aci)/180))*15;
	
yelkovan_x=(cos((pi*yelkovan_aci)/180))*18+95;
	
yelkovan_y=30-(sin((pi*yelkovan_aci)/180))*18;
	
saniye_x=(cos((pi*saniye_aci)/180))*20+95;
	
saniye_y=30-(sin((pi*saniye_aci)/180))*20;
	
glcd_line(95,30,akrep_x,akrep_y,1);
	
glcd_line(95,30,yelkovan_x,yelkovan_y,1);
	
glcd_line(95,30,saniye_x,saniye_y,1);
	

}
void SysTick_Handler(void)
{
	
j++;
	
if(
j==4&&stop==1)
	
//Ayarlama modunda yanip sönme hizi
	
{
	
	
yanson++;
	
	
clock_write();
	
	
j=0;
	
}
}
void SysTickStart(void)
{
	
SysTick->LOAD=100000000;//45ms preriyot
	
SysTick->VAL =(0x00);
	
SysTick->CTRL=0x07;
}
void SysTickStop(void)
{
	
SysTick->CTRL=0x00;
}
void clock_write(void)
{
	
 
	
if(
select%2==0)
	
	
{
	
	
	
current_time=RTCGetTime();
	
	
	
seccurrent_time.RTC_Sec;
	
	
	
min=current_time.RTC_Min;
	
	
	
hour=current_time.RTC_Hour;
	
	
	
mon=current_time.RTC_Mon;
	
	
	
mday=current_time.RTC_Mday;
	
	
	
year=current_time.RTC_Year;
	
	
	
wday=current_time.RTC_Wday;
	
	
}
	
	
if(
select%2!=0)
	
	
{
	
	
	
alarm_time=RTCGetAlarmTime();
	
	
	
secalarm_time.RTC_Sec;
	
	
	
minalarm_time.RTC_Min;
	
	
	
hour=alarm_time.RTC_Hour;
	
	
	
monalarm_time.RTC_Mon;
	
	
	
mday=alarm_time.RTC_Mday;
	
	
	
year=alarm_time.RTC_Year;
	
	
	
wday=alarm_time.RTC_Wday;
	

	
	
}
	
	
if((
setting==1&&stop==1)&&yanson%2==0)
	
	
{
	
	
	
f[0]=' ';
	
	
	
f[1]=' ';
	
	
	
f[2]=':';
	
	
}
	
	
else if((
stop==0&&hour<10)||(hour<10&&yanson%2!=0&&setting==1)||(hour<10&&setting!=1))
	
	
sprintf(f,"0%d:",hour);
	
	
else if((
stop==0&&hour>=10)||(hour>=10&&yanson%2!=0&&setting==1)||(hour>=10&&setting!=1))
	
	
sprintf(f,"%d:",hour);
	
	
if((
setting==2&&stop==1)&&yanson%2==0)
	
	
{
	
	
	
f[3]=' ';
	
	
	
f[4]=' ';
	
	
	
f[5]=':';
	
	
}
	
	
else if((
stop==0&&min<10)||(min<10&&yanson%2!=0&&setting==2)||(min<10&&setting!=2))
	
	
sprintf(f+3,"0%d:",min);
	
	
else if(
stop==0&&min>=10||(min>=10&&yanson%2!=0&&setting==2)||(min>=10&&setting!=2))
	
	
sprintf(f+3,"%d:",min);
	
	
if((
setting==3&&stop==1)&&yanson%2==0)
	
	
{
	
	
	
f[6]=' ';
	
	
	
f[7]=' ';
	
	
}
	
	
else if((
stop==0&&sec<10)||(sec<10&&yanson%2!=0&&setting==3)||(sec<10&&setting!=3))
	
	
sprintf(f+6,"0%d",sec);
	
	
else if((
stop==0&&sec>=10)||(sec>=10&&yanson%2!=0&&setting==3)||(sec>=10&&setting!=3))
	
	
sprintf(f+6,"%d",sec);
	
	
glcd_fillScreen(0);
	
	
glcd_rect(1,0,63,20,0,1);
	
	
glcd_rect(1,22,63,53,0,1);
	
	
glcd_text57(3,55,"Yusuf Yamak",1,1);
	
	
analog_saat();
	
	
if(
select%2==0)
	
	
{
	
    
glcd_text57(3,1,"Saat",1,1);
	
	
glcd_text57(3,24,"Tarih",1,1);
	
	

	
	
else
	
	

	
	
glcd_text57(3,1,"Alrm Saati",1,1);
	
	
glcd_text57(3,24,"Alrm Tarhi",1,1);
	
	
}
	
	
glcd_text57(3,11,f,1,1);
	
	
if((
setting==4&&stop==1)&&yanson%2==0)
	
	
{
	
	
	
g[0]=' ';
	
	
	
g[1]=' ';
	
	
	
g[2]='/';
	
	
}
	
	
else if((
stop==0&&mday<10)||(mday<10&&yanson%2!=0&&setting==4)||(mday<10&&setting!=4))
	
	
sprintf(g,"0%d/",mday);
	
	
else if(
stop==0&&mday>=10||(mday>=10&&yanson%2!=0&&setting==4)||(mday>=10&&setting!=4))
	
	
sprintf(g,"%d/",mday);
	
	
if((
setting==5&&stop==1)&&yanson%2==0)
	
	
{
	
	
	
g[3]=' ';
	
	
	
g[4]=' ';
	
	
	
g[5]='/';
	
	
}
	
	
else if((
stop==0&&mon<10)||(mon<10&&yanson%2!=0&&setting==5)||(mon<10&&setting!=5))
	
	
sprintf(g+3,"0%d/",mon);
	
	
else if((
stop==0&&mon>=10||mon>=10&&yanson%2!=0&&setting==5)||(mon>=10&&setting!=5))
	
	
sprintf(g+3,"%d/",mon);
	
	
if((
setting==6&&stop==1)&&yanson%2==0)
	
	
{
	
	
	
g[6]=' ';
	
	
	
g[7]=' ';
	
	
	
g[8]=' ';
	
	
	
g[9]=' ';
	
	
	
g[10]='\0';
	
	
}
	
	
else if(
stop==0||(yanson%2!=0&&setting==6)||setting!=6)
	
	
sprintf(g+6,"%d",year);
	
	
glcd_text57(3,34,g,1,1);
	
	
if(
setting==7&&stop==1&&yanson%2==0)
	
	
glcd_text57(37,55,"     ",1,1);
	
	
else if(
stop==0||(yanson%2!=0&&setting==7)||setting!=7)
	
	
{
	
	
	
switch(
wday)
	
	
	
{
	
	
	
	
   
	
	
	
	
case 
0:glcd_text57(4,44,"Pazar",1,1);
	
	
	
	
break;
	
	
	
	
case 
1:glcd_text57(4,44,"Pazartesi",1,1);
	
	
	
	
break;
	
	
	
	
case 
2:glcd_text57(4,44,"Sali",1,1);
	
	
	
	
break;
	
	
	
	
case 
3:glcd_text57(4,44,"Carsamba",1,1);
	
	
	
	
break;
	
	
	
	
case 
4:glcd_text57(4,44,"Persembe",1,1);
	
	
	
	
break;
	
	
	
	
case 
5:glcd_text57(4,44,"Cuma",1,1);
	
	
	
	
break;
	
	
	
	
case 
6:glcd_text57(4,44,"Cumartesi",1,1);
	
	
	
	
break;
	
	
	
	
default:
	
	
	
	
break;
	
	
	
}
	
	
}
}

void start_timer(uint32_t wait)
{

	
  
LPC_TIM1->TCR=0x02;//reset timer
      
LPC_TIM1->IR=0xFF;//tüm kesmeleri resetle
      
LPC_TIM1->MR1=wait*24000;
      
LPC_TIM1->MCR=1<<3;
      
LPC_TIM1->TCR=0x01;//start timer
	
  
LPC_TIM1->PR=0x00;
	
  
NVIC_EnableIRQ(TIMER1_IRQn);
                    
}
void stop_timer(void)
{
	
LPC_TIM1->TCR=2;
	
NVIC_DisableIRQ(TIMER1_IRQn);
}
void TIMER1_IRQHandler(void)
{
	
if(
start_count==0)//ayarlama modunda degilken timer acilmissa
	
{
	
	
stop=1;
	
	
setting=1;
	
	
alarm_on=0;
	
	
j=0;
	
	
SysTickStart();
	
}
	
stop_timer();
	
start=0;
}
void RTC_IRQHandler (void
{
	
	

	
	
if(
LPC_RTC->ILR&0x01//artis kesmesi olusmussa
	
	
{
	

	
	
LPC_RTC->ILR|=1//kesme bayragi temizle 
	
	

	
	
if(
pwm==1)//alarm 10 saniye boyunca çalacak
	
	
{
	
	
	
z++;
	
	
	
if(
z==10)
	
	
	
{
	
	
	
	
pwm_stop();
	
	
	
	
z=0;
	
	
	
}
	
	
}
	
	
clock_write();
	

	
	
}
	

	
	
if((
LPC_RTC->ILR)&0x02&&alarm_on==1)
	
// Alarm kesmesi olusmussa
	
	
{
	
	
	
LPC_RTC->ILR|=2;//kesme bayragi temizle
	
	
	
pwm_start();
	
	
    
glcd_fillScreen(0);
	
	
	
glcd_text57(30,20,"ALARM",2,1);
	
	
	

	
	
	
SysTickStart();
	

	
	
}
	
	

}
void pll_hazirla(void)
{
	
LPC_SC->SCS=0x20;
	
LPC_SC->CLKSRCSEL=0x01;
	
//select main oscilator
	
LPC_SC->CCLKCFG=0x03;
	
//pllclk/4
	
LPC_SC->PLL0CON=0x01;
	
//pll activeted
	
LPC_SC->PLL0CFG=0x20031//msel=49,nsel=2;
	
LPC_SC->PLL0FEED=0xAA;
    
LPC_SC->PLL0FEED=0x55;
	
while(!(
LPC_SC->PLL0STAT&(1<<26)));
	
LPC_SC->PLL0CON=0x07;
	
LPC_SC->PLL0FEED=0xAA;
    
LPC_SC->PLL0FEED=0x55;
	
LPC_SC->PCLKSEL0=0;
}
void pwm_start(void)
{
	
LPC_PINCON->PINSEL4|=1<<10;
	
LPC_PWM1->MR0=25000000;//FREKANS=PCLK/25000000
	
LPC_PWM1->MR6=10000000;//DUTY CYCLE=10/25
	
LPC_PWM1->MCR=2;
	
LPC_PWM1->PCR=1<<14;//PWM6 OUTPUT ENABLED
	
LPC_PWM1->TCR=0x02;
	
LPC_PWM1->LER=0x40;//MCR YAZILAN DEGER AKTIFLESTI
	
LPC_PWM1->TCR=0x09;
	
pwm=1;
}
void pwm_stop(void)
{
	
LPC_PWM1->PCR=0;
	
LPC_PWM1->TCR=0x00;
	
pwm=0;
}
int main(void)
{
	
int m1=0,m2=0,s=0;
	
pll_hazirla();
	
LPC_GPIO2->FIODIR=0xFF;
	
LPC_GPIO2->FIOCLR=0xFF;
	
LPC_GPIO0->FIODIR=0xFFFFFFFF;
	
LPC_GPIO0->FIOCLR=0xFFFFFFFF;
	
LPC_GPIO1->FIODIR=0xFFFFFFFF;
	
LPC_GPIO1->FIOCLR=0xFFFFFFFF;
	
LPC_GPIO1->FIODIR&=~((1<<25)|(1<<26)|(1<<27)|(1<<28)|(1<<29));//joystick icin 
	
glcd_init();
	
rtc_init();
	
rtc_start();
	
NVIC_EnableIRQ(RTC_IRQn);
	
RTCAlarmMask(AMRDOM|AMRDOW|AMRDOY|AMRMON|AMRYEAR);//alarm'i sadece saat dakika ve saniye etkileyecek
	
while(
1)
	
{
	
	
	
	

	
  
	

	
   if(!(
LPC_GPIO1->FIOPIN&(1<<25))) //alarm time ya da local time secme
	
	
	
	
{
	
	
	
	
	
if(
stop==1)
	
	
	
	
	
setting=1;
	
	
	
	
	
if(
s==0)
	
	
	
	
	
{
	
	
	
	
	
   
	
select++;
	
	
	
	
	
	
s=1;
	

	
	
	
	
	
}
	
	
	
	
}
	
	
	
	
else if((
LPC_GPIO1->FIOPIN&(1<<25)))
	
	
	
	
{
	
	
	
	
	
s=0;
	
	
	
	
}
	
   if(
stop==0)
	
//ayarlama modunda degilse
	
   {
	
   if(
start==0)
	
   {
	
	
    if(!(
LPC_GPIO2->FIOPIN&(1<<11)))//butonu basilmissa
	
	
	
{
	
	
    
start_timer(1000);
	
	
    
start=1;
	
	
	
start_count=0;
	
	
	
}
	
   }
	
   else
	
   {
	
	
   
	
if((
LPC_GPIO2->FIOPIN&(1<<11)))
	
//butona basilmamissa
	
	
	
{
	
	
	
stop_timer();
	
	
	
start=0;
	
	
	
}
	
	
}
	
	
}
	
	
else if(
stop==1)
	
//ayarlama modunda ise
	
	
{
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<28)))//joystick saga hareket ettirilmisse
	
	
	
	
{
	
	
	
	
	
if(
m2==0)
	
	
	
	
	
{
	
	
	
	
	
	
setting++;
	
	
	
	
	
	
if(
setting==8)
	
	
	
	
	
	
{
	
	
	
	
	
	
setting=1;
	
	
	
	
	
	
}
	
	
	
	
	
	
m2=1;
	

	
	
	
	
	
}
	
	
	
	
}
	
	
	
else if((
LPC_GPIO1->FIOPIN&(1<<28)))
	
	
	
	
	
{
	
	
	
	
	
	
m2=0;
	
	
	
	
	
}
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<27)))//joystick sola hareket ettirilmisse
	
	
	
	
{
	
	
	
	
	
if(
m1==0)
	
	
	
	
	
{
	
	
	
	
	
	
setting--;
	
	
	
	
	
	
if(
setting==0)
	
	
	
	
	
	
{
	
	
	
	
	
	
setting=7;
	
	
	
	
	
	
}
	
	
	
	
	
	
m1=1;
	

	
	
	
	
	
}
	
	
	
	
}
	
	
	
else if((
LPC_GPIO1->FIOPIN&(1<<27)))
	
	
	
	
	
{
	
	
	
	
	
	
m1=0;
	
	
	
	
	
}
	
	

	
	
	
if(
setting==1)//Saat ayari
	
	
	
{
	
	
	
	
	

	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<29)))
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
//local time saat ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Hour=LPC_RTC->HOUR;
	
	
	
	
	
	
	
local_time.RTC_Hour++;
	
	
	
	
	
	
	
if(
local_time.RTC_Hour==24)
	
	
	
	
	
	
	
local_time.RTC_Hour=0;
	
	
	
	
	
	
	
LPC_RTC->HOUR=local_time.RTC_Hour;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1)) //alarm time saat ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Hour=LPC_RTC->ALHOUR;
	
	
	
	
	
	
	
alarm_time.RTC_Hour++;
	
	
	
	
	
	
	
if(
alarm_time.RTC_Hour==24)
	
	
	
	
	
	
	
alarm_time.RTC_Hour=0;
	
	
	
	
	
	
	
LPC_RTC->ALHOUR=alarm_time.RTC_Hour;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	

	
	
	
	
}
	
	
	
	
	

	
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<26)))
	
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Hour=LPC_RTC->HOUR//local time saat ayari azalis
	
	
	
	
	
	
	
local_time.RTC_Hour--;
	
	
	
	
	
	
	
if(
local_time.RTC_Hour<0)
	
	
	
	
	
	
	
local_time.RTC_Hour=23;
	
	
	
	
	
	
	
LPC_RTC->HOUR=local_time.RTC_Hour;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1))
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Hour=LPC_RTC->ALHOUR;//alarm time saat ayari azalis
	
	
	
	
	
	
	
alarm_time.RTC_Hour--;
	
	
	
	
	
	
	
if(
local_time.RTC_Hour<0)
	
	
	
	
	
	
	
alarm_time.RTC_Hour=23;
	
	
	
	
	
	
	
LPC_RTC->ALHOUR=alarm_time.RTC_Hour;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
}
	
	

	
	
	
}
	
	
	
else if(
setting==2)
	
//Dakika ayari
	
	
	
{
	
	
	
	
 
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<29)))
	
	
	
	
{
	
	
	
	
	
	

	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1)) //local time dakika ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Min=LPC_RTC->MIN;
	
	
	
	
	
	
	
local_time.RTC_Min++;
	
	
	
	
	
	
	
if(
local_time.RTC_Min==60)
	
	
	
	
	
	
	
local_time.RTC_Min=0;
	
	
	
	
	
	
	
LPC_RTC->MIN=local_time.RTC_Min;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1))
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Min=LPC_RTC->ALMIN//alarm time dakika ayari artis
	
	
	
	
	
	
	
alarm_time.RTC_Min++;
	
	
	
	
	
	
	
if(
alarm_time.RTC_Min==60)
	
	
	
	
	
	
	
alarm_time.RTC_Min=0;
	
	
	
	
	
	
	
LPC_RTC->ALMIN=alarm_time.RTC_Min;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<26)))
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
//local time dakika ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Min=LPC_RTC->MIN;
	
	
	
	
	
	
	
local_time.RTC_Min--;
	
	
	
	
	
	
	
if(
local_time.RTC_Min<0)
	
	
	
	
	
	
	
local_time.RTC_Min=59;
	
	
	
	
	
	
	
LPC_RTC->MIN=local_time.RTC_Min;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1))
	
//alarm time dakika ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Min=LPC_RTC->ALMIN;
	
	
	
	
	
	
	
alarm_time.RTC_Min--;
	
	
	
	
	
	
	
if(
local_time.RTC_Min<0)
	
	
	
	
	
	
	
alarm_time.RTC_Min=59;
	
	
	
	
	
	
	
LPC_RTC->ALMIN=alarm_time.RTC_Min;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	

	
	
	
}
	
	
	
else if(
setting==3)
	
//saniye ayari
	
	
	
{
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<29)))
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))//local time saniye ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
LPC_RTC->SEC=0;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1)) // alarm time saniye ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Sec=LPC_RTC->ALSEC;
	
	
	
	
	
	
	
alarm_time.RTC_Sec++;
	
	
	
	
	
	
	
if(
alarm_time.RTC_Sec==60)
	
	
	
	
	
	
	
alarm_time.RTC_Sec=0;
	
	
	
	
	
	
	
LPC_RTC->ALSEC=alarm_time.RTC_Sec;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<26)))
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
//local time saniye ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
LPC_RTC->SEC=0;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1)) //alarm time saniye ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Sec=LPC_RTC->ALSEC;
	
	
	
	
	
	
	
alarm_time.RTC_Sec--;
	
	
	
	
	
	
	
if(
local_time.RTC_Sec<0)
	
	
	
	
	
	
	
alarm_time.RTC_Sec=23;
	
	
	
	
	
	
	
LPC_RTC->ALSEC=alarm_time.RTC_Sec;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	
	

	
	
	
}
	
	
	
else if(
setting==4)
	
 
//ayin günü ayari
	
	
	
{
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<29)))
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Mday=LPC_RTC->DOM//local time ay gunu ayari artis
	
	
	
	
	
	
	
local_time.RTC_Mday++;
	
	
	
	
	
	
	
if(
local_time.RTC_Mday==32)
	
	
	
	
	
	
	
local_time.RTC_Mday=1;
	
	
	
	
	
	
	
LPC_RTC->DOM=local_time.RTC_Mday;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1)) //alarm time ay gunu ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Mday=LPC_RTC->ALDOM;
	
	
	
	
	
	
	
alarm_time.RTC_Mday++;
	
	
	
	
	
	
	
if(
alarm_time.RTC_Mday==32)
	
	
	
	
	
	
	
alarm_time.RTC_Mday=1;
	
	
	
	
	
	
	
LPC_RTC->ALDOM=alarm_time.RTC_Mday;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<26)))
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
//local time ay gunu ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Mday=LPC_RTC->DOM;
	
	
	
	
	
	
	
local_time.RTC_Mday--;
	
	
	
	
	
	
	
if(
local_time.RTC_Mday<0)
	
	
	
	
	
	
	
local_time.RTC_Mday=31;
	
	
	
	
	
	
	
LPC_RTC->DOM=local_time.RTC_Mday;
	
	
	
	
	
	
	
clock_write();
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1))
	
// alarm time ay gunu ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Mday=LPC_RTC->ALDOM;
	
	
	
	
	
	
	
alarm_time.RTC_Mday--;
	
	
	
	
	
	
	
if(
local_time.RTC_Mday<0)
	
	
	
	
	
	
	
alarm_time.RTC_Mday=31;
	
	
	
	
	
	
	
LPC_RTC->ALDOM=alarm_time.RTC_Mday;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	
	

	
	
	
}
	
	
	
else if(
setting==5//ay ayari
	
	
	
{
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<29))) //local time ay ayari artis
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Mon=LPC_RTC->MONTH;
	
	
	
	
	
	
	
local_time.RTC_Mon++;
	
	
	
	
	
	
	
if(
local_time.RTC_Mon==13)
	
	
	
	
	
	
	
local_time.RTC_Mon=1;
	
	
	
	
	
	
	
LPC_RTC->MONTH=local_time.RTC_Mon;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1))
	
//alarm time ay ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Mon=LPC_RTC->ALMON;
	
	
	
	
	
	
	
alarm_time.RTC_Mon++;
	
	
	
	
	
	
	
if(
alarm_time.RTC_Mday==13)
	
	
	
	
	
	
	
alarm_time.RTC_Mon=1;
	
	
	
	
	
	
	
LPC_RTC->ALMON=alarm_time.RTC_Mon;
	
	
	
	
	
	
	
clock_write();
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<26)))
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
//local time ay ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Mon=LPC_RTC->MONTH;
	
	
	
	
	
	
	
local_time.RTC_Mon--;
	
	
	
	
	
	
	
if(
local_time.RTC_Mon==0)
	
	
	
	
	
	
	
local_time.RTC_Mon=12;
	
	
	
	
	
	
	
LPC_RTC->MONTH=local_time.RTC_Mon;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1))
	
//alarm time ay ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Mon=LPC_RTC->ALMON;
	
	
	
	
	
	
	
alarm_time.RTC_Mon--;
	
	
	
	
	
	
	
if(
local_time.RTC_Mon==0)
	
	
	
	
	
	
	
alarm_time.RTC_Mon=12;
	
	
	
	
	
	
	
LPC_RTC->ALMON=alarm_time.RTC_Mon;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	

	
	
	
}
	
	
	
else if(
setting==6)
	
//yil ayari
	
	
	
{
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<29))) //local time yil ayari artis
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Year=LPC_RTC->YEAR;
	
	
	
	
	
	
	
local_time.RTC_Year++;
	
	
	
	
	
	
	
if(
local_time.RTC_Year==2100)
	
	
	
	
	
	
	
local_time.RTC_Year=2000;
	
	
	
	
	
	
	
LPC_RTC->YEAR=local_time.RTC_Year;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1)) //alarm time yil ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Year=LPC_RTC->ALYEAR;
	
	
	
	
	
	
	
alarm_time.RTC_Year++;
	
	
	
	
	
	
	
if(
alarm_time.RTC_Year==2100)
	
	
	
	
	
	
	
alarm_time.RTC_Year=2000;
	
	
	
	
	
	
	
LPC_RTC->ALYEAR=alarm_time.RTC_Year;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<26)))//local time yil ayari azalis
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Year=LPC_RTC->YEAR;
	
	
	
	
	
	
	
local_time.RTC_Year--;
	
	
	
	
	
	
	
if(
local_time.RTC_Year==1999)
	
	
	
	
	
	
	
local_time.RTC_Year=2099;
	
	
	
	
	
	
	
LPC_RTC->YEAR=local_time.RTC_Year;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1)) //alarm time yil ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Year=LPC_RTC->ALYEAR;
	
	
	
	
	
	
	
alarm_time.RTC_Year--;
	
	
	
	
	
	
	
if(
local_time.RTC_Year==1999)
	
	
	
	
	
	
	
alarm_time.RTC_Year=2099;
	
	
	
	
	
	
	
LPC_RTC->ALYEAR=alarm_time.RTC_Year;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	

	
	
	
}
	
	
	
	
else if(
setting==7)
	
  
//haftanin gunu ayari
	
	
	
	
{
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<29)))
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1)) //local time haftanin gunu ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Wday=LPC_RTC->DOW;
	
	
	
	
	
	
	
local_time.RTC_Wday++;
	
	
	
	
	
	
	
if(
local_time.RTC_Wday==7)
	
	
	
	
	
	
	
local_time.RTC_Wday=0;
	
	
	
	
	
	
	
LPC_RTC->DOW=local_time.RTC_Wday;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1))
	
//alarm time haftanin günü ayari artis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Wday=LPC_RTC->ALDOW;
	
	
	
	
	
	
	
alarm_time.RTC_Wday++;
	
	
	
	
	
	
	
if(
alarm_time.RTC_Wday==7)
	
	
	
	
	
	
	
alarm_time.RTC_Wday=0;
	
	
	
	
	
	
	
LPC_RTC->ALDOW=alarm_time.RTC_Wday;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	
	
	
if(!(
LPC_GPIO1->FIOPIN&(1<<26))) //local time haftanin gunu ayari azalis
	
	
	
	
{
	
	
	
	
	
	
if(
stop==0||(select%2==0&&stop==1))
	
	
	
	
	
	
{
	
	
	
	
	
	
	
local_time.RTC_Wday=LPC_RTC->DOW;
	
	
	
	
	
	
	
local_time.RTC_Wday--;
	
	
	
	
	
	
	
if(
local_time.RTC_Wday<0)
	
	
	
	
	
	
	
local_time.RTC_Wday=6;
	
	
	
	
	
	
	
LPC_RTC->DOW=local_time.RTC_Wday;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
	
	
if((
select%2==1&&stop==1)) //alarm time haftanin gunu ayari azalis
	
	
	
	
	
	
{
	
	
	
	
	
	
	
alarm_time.RTC_Wday=LPC_RTC->ALDOW;
	
	
	
	
	
	
	
alarm_time.RTC_Wday--;
	
	
	
	
	
	
	
if(
local_time.RTC_Wday<0)
	
	
	
	
	
	
	
alarm_time.RTC_Wday=6;
	
	
	
	
	
	
	
LPC_RTC->ALDOW=alarm_time.RTC_Wday;
	
	
	
	
	
	
	
DelayMs(0,400);
	
	
	
	
	
	
}
	
	
	
	
}
	
	
	

	
	
	
}
	
	
	
 if(!(
LPC_GPIO2->FIOPIN&(1<<10))) //Ayarlama tamam
	
	
	
	
{
	
	
	
	
	
 
	
stop=0;
	
	
	
	
	
	
setting=0;
	
	
	
	
	
	
yanson=0;
	
	
	
	
	
	
j=0;
	
	
	
	
	
	
rtc_stop();
	
	
	
	
	
	
alarm_on=1;
	
	
	
	
	
	
SysTickStop();
	
	
	
	
	
	
glcd_fillScreen(0);
	
	
	
	
	
	
glcd_text57(17,15,"AYARLAMA",2,1);
	
	
	
	
	
	
glcd_text57(8,35,"TAMAMLANDI",2,1);
	
	
	
	
	
	
DelayMs(0,1000);
	
	
	
	
	
	
rtc_start();
	
	
	
	
}
	
}
	
   
	
}
}

rtc.c:
#include <lpc17xx.h>
#include "yusuf_rtc.h"

void rtc_init(void)
{
	
LPC_SC->PCONP |= (<< 9);
	
if(!(
LPC_RTC->RTC_AUX)&(0x01<<4))
	
{
       
LPC_RTC->RTC_AUX|=0x01<<4;
	
}
	
LPC_RTC->AMR 0;
  
	
LPC_RTC->CIIR 1;
  
	
LPC_RTC->CCR 0;
  
	
return;
}

void rtc_start(void)
{
	

	
LPC_RTC->CCR|=0x01;
	
LPC_RTC->ILR |= 0x03;

}

void rtc_restart(void)
{

	
LPC_RTC->CCR|=0x02;
}

void rtc_stop(void)
{
	
LPC_RTC->CCR=0;
	


}
void RTCSetTime(RTC_TIME Time)
{
	
LPC_RTC->SEC Time.RTC_Sec;
    
LPC_RTC->MIN Time.RTC_Min;
  
	
LPC_RTC->HOUR Time.RTC_Hour;
  
	
LPC_RTC->DOM Time.RTC_Mday;
  
	
LPC_RTC->DOW Time.RTC_Wday;
  
	
LPC_RTC->DOY Time.RTC_Yday;
  
	
LPC_RTC->MONTH Time.RTC_Mon;
  
	
LPC_RTC->YEAR Time.RTC_Year;
}

RTC_TIME RTCGetTime(void)
{
	
RTC_TIME LocalTime;
	

	
LocalTime.RTC_Sec LPC_RTC->SEC;
  
	
LocalTime.RTC_Min LPC_RTC->MIN;
  
	
LocalTime.RTC_Hour LPC_RTC->HOUR;
  
	
LocalTime.RTC_Mday LPC_RTC->DOM;
  
	
LocalTime.RTC_Wday LPC_RTC->DOW;
  
	
LocalTime.RTC_Yday LPC_RTC->DOY;
  
	
LocalTime.RTC_Mon LPC_RTC->MONTH;
  
	
LocalTime.RTC_Year LPC_RTC->YEAR;
  
	
return ( 
LocalTime );    
}
void RTCSetAlarm(RTC_TIME Time)
{
	
LPC_RTC->ALSEC Time.RTC_Sec;
    
LPC_RTC->ALMIN Time.RTC_Min;
  
	
LPC_RTC->ALHOUR Time.RTC_Hour;
  
	
LPC_RTC->ALDOM Time.RTC_Mday;
  
	
LPC_RTC->ALDOW Time.RTC_Wday;
  
	
LPC_RTC->ALDOY Time.RTC_Yday;
  
	
LPC_RTC->ALMON Time.RTC_Mon;
  
	
LPC_RTC->ALYEAR Time.RTC_Year;
}
RTC_TIME RTCGetAlarmTime(void)
{
	
RTC_TIME AlarmTime;
	

	
AlarmTime.RTC_Sec LPC_RTC->ALSEC;
  
	
AlarmTime.RTC_Min LPC_RTC->ALMIN;
  
	
AlarmTime.RTC_Hour LPC_RTC->ALHOUR;
  
	
AlarmTime.RTC_Mday LPC_RTC->ALDOM;
  
	
AlarmTime.RTC_Wday LPC_RTC->ALDOW;
  
	
AlarmTime.RTC_Yday LPC_RTC->ALDOY;
  
	
AlarmTime.RTC_Mon LPC_RTC->ALMON;
  
	
AlarmTime.RTC_Year LPC_RTC->ALYEAR;
  
	
return ( 
AlarmTime );    
}
void RTCAlarmMask(uint32_t AlarmMask)
{
	
LPC_RTC->AMR=AlarmMask;
}


rtc.h:
typedef struct{
	
int RTC_Sec;
	
int RTC_Min;
	
int RTC_Hour;
	
int RTC_Mday;
	
int RTC_Year;
	
int RTC_Mon;
	
int RTC_Wday;
	
int RTC_Yday;
}
RTC_TIME;

#define AMRSEC 
	
0x01
#define AMRMIN 
	
0x02
#define AMRHOUR 0x04
#define AMRDOM  0x08
#define AMRDOW  0x10
#define AMRDOY  0x20
#define AMRMON  0x40
#define AMRYEAR 0x80

 
extern void rtc_init(void);
extern void rtc_start(void);
extern void rtc_restart(void);
extern void rtc_stop(void);
extern void RTCSetTime(RTC_TIME time);
extern RTC_TIME RTCGetTime(void);
extern RTC_TIME RTCGetAlarmTime(void);

delay.c:
#include <lpc17xx.h>
#include "yusuf_lpc17xx_delay.h"
void DelayMs(int timer_num,int bekle)
{
     if(
timer_num==0)
     {
	
 
	
	
	
	

                     
LPC_TIM0->TCR=0x02;//reset timer
                     
LPC_TIM0->IR=0xFF;//tüm kesmeleri restle
                     
LPC_TIM0->MR0=bekle*25000;
                     
LPC_TIM0->MCR=0x04;
                     
LPC_TIM0->TCR=0x01;//start timer
	
	
             
LPC_TIM0->PR=0x00;//prescalar deger.Örnegin 2 oldugunda her 3 tick de bir sayar.
                     
while(LPC_TIM0->TCR&0x01);//tasana kadar bekle
     
}
     if(
timer_num==1)
     {
                     
LPC_TIM1->TCR=0x02;
                     
LPC_TIM1->IR=0xFF;
                     
LPC_TIM1->MR0=bekle*25000;
                     
LPC_TIM1->MCR=0x04;
                     
LPC_TIM1->TCR=0x01;
                     while(
LPC_TIM1->TCR&0x01);
     }
     return;
}
void DelayUs(int timer_num,int bekle)
{
     if(
timer_num==0)
     {
                     
LPC_TIM0->TCR=0x02;
                     
LPC_TIM0->IR=0xFF;
                     
LPC_TIM0->MR0=bekle*12;
                     
LPC_TIM0->MCR=0x04;
                     
LPC_TIM0->TCR=0x01;
                     while(
LPC_TIM0->TCR&0x01);
     }
     if(
timer_num==1)
     {
                     
LPC_TIM1->TCR=0x02;
                     
LPC_TIM1->IR=0xFF;
                     
LPC_TIM1->MR0=bekle*25;
                     
LPC_TIM1->MCR=0x04;
                     
LPC_TIM1->TCR=0x01;
                     while(
LPC_TIM1->TCR&0x01);
     }
     return;


Note:GPIO2.5 pinine buzzer bağlandığında alarm vakti gelince çalıyo fakat bu vdeoda buzzer bağlamadığım için sadece ekrana ALARM yazıyo.

Okan AKÇA

hocam cok güzel olmuş ama ilk yorum yapan ben oldum bi arm cılgınlıgı başlamıstı  gercekten arm ile ilgilenenler icin bulunmaz bir kaynak

M_B

@yamak hocam;
paylaşımınız ve projeniz icin tebrik ederim. ARM ye başlayanlar için guzel bir örnek.
Bende de LPC1768 kiti var ama henuz bir adım atamadım. İnşallah kısa zaman da onunla çalışmaya başlayacağım.

Hocam
yusuf_rtc.h
yusuf_lpc17xx_delay.h
lpc_glcd.h

bunlarıda paylaşabilirmisiniz.

Teşekkürler
İmkanın sınırlarını görmek için imkansızı denemek lazım.                                                             Fatih Sultan Mehmet

Kadir Can(16F84)


yamak

evet arkadaslar rtc.h yusuf_rtc.h. su an telefondan giriyorum nete bilgisayardan girdimde geri kalan kutuphane dosyalarini da paylasirim.

yamak

@ M_B
Uygulamanın geri kalan kütüphane dosyaları:

yusuf_lpc17xx_delay.h

extern void DelayMs
(int timer_num,int bekle);
extern void DelayUs(int timer_num,int bekle) ;


lpc_glcd.c:

#include <lpc17xx.h>
#include <yusuf_lpc17xx_delay.h>
#include <lpc_glcd.h>
#include <string.h>
const unsigned char TEXT[51][5] ={0x000x000x000x000x00// SPACE
                         
0x000x000x5F0x000x00// !
                         
0x000x030x000x030x00// "
                         
0x140x3E0x140x3E0x14// #
                         
0x240x2A0x7F0x2A0x12// $
                         
0x430x330x080x660x61// %
                         
0x360x490x550x220x50// &
                         
0x000x050x030x000x00// '
                         
0x000x1C0x220x410x00// (
                         
0x000x410x220x1C0x00// )
                         
0x140x080x3E0x080x14// *
                         
0x080x080x3E0x080x08// +
                         
0x000x500x300x000x00// ,
                         
0x080x080x080x080x08// -
                         
0x000x600x600x000x00// .
                         
0x200x100x080x040x02// /
                         
0x3E0x510x490x450x3E// 0
                         
0x040x020x7F0x000x00// 1
                         
0x420x610x510x490x46// 2
                         
0x220x410x490x490x36// 3
                         
0x180x140x120x7F0x10// 4
                         
0x270x450x450x450x39// 5
                         
0x3E0x490x490x490x32// 6
                         
0x010x010x710x090x07// 7
                         
0x360x490x490x490x36// 8
                         
0x260x490x490x490x3E// 9
                         
0x000x360x360x000x00// :
                         
0x000x560x360x000x00// ;
                         
0x080x140x220x410x00// <
                         
0x140x140x140x140x14// =
                         
0x000x410x220x140x08// >
                         
0x020x010x510x090x06// ?
                         
0x3E0x410x590x550x5E// @
                         
0x7E0x090x090x090x7E// A
                         
0x7F0x490x490x490x36// B
                         
0x3E0x410x410x410x22// C
                         
0x7F0x410x410x410x3E// D
                         
0x7F0x490x490x490x41// E
                         
0x7F0x090x090x090x01// F
                         
0x3E0x410x410x490x3A// G
                         
0x7F0x080x080x080x7F// H
                         
0x000x410x7F0x410x00// I
                         
0x300x400x400x400x3F// J
                         
0x7F0x080x140x220x41// K
                         
0x7F0x400x400x400x40// L
                         
0x7F0x020x0C0x020x7F// M
                         
0x7F0x020x040x080x7F// N
                         
0x3E0x410x410x410x3E// O
                         
0x7F0x090x090x090x06// P
                         
0x1E0x210x210x210x5E// Q
                         
0x7F0x090x090x090x76};// R

const unsigned char TEXT2[44][5]={0x260x490x490x490x32// S
                         
0x010x010x7F0x010x01// T
                         
0x3F0x400x400x400x3F// U
                         
0x1F0x200x400x200x1F// V
                         
0x7F0x200x100x200x7F// W
                         
0x410x220x1C0x220x41// X
                         
0x070x080x700x080x07// Y
                         
0x610x510x490x450x43// Z
                         
0x000x7F0x410x000x00// [
                         
0x020x040x080x100x20// 
                         
0x000x000x410x7F0x00// ]
                         
0x040x020x010x020x04// ^
                         
0x400x400x400x400x40// _
                         
0x000x010x020x040x00// `
                         
0x200x540x540x540x78// a
                         
0x7F0x440x440x440x38// b
                         
0x380x440x440x440x44// c
                         
0x380x440x440x440x7F// d
                         
0x380x540x540x540x18// e
                         
0x040x040x7E0x050x05// f
                         
0x080x540x540x540x3C// g
                         
0x7F0x080x040x040x78// h
                         
0x000x440x7D0x400x00// i
                         
0x200x400x440x3D0x00// j
                         
0x7F0x100x280x440x00// k
                         
0x000x410x7F0x400x00// l
                         
0x7C0x040x780x040x78// m
                         
0x7C0x080x040x040x78// n
                         
0x380x440x440x440x38// o
                         
0x7C0x140x140x140x08// p
                         
0x080x140x140x140x7C// q
                         
0x000x7C0x080x040x04// r
                         
0x480x540x540x540x20// s
                         
0x040x040x3F0x440x44// t
                         
0x3C0x400x400x200x7C// u
                         
0x1C0x200x400x200x1C// v
                         
0x3C0x400x300x400x3C// w
                         
0x440x280x100x280x44// x
                         
0x0C0x500x500x500x3C// y
                         
0x440x640x540x4C0x44// z
                         
0x000x080x360x410x41// {
                         
0x000x000x7F0x000x00// |
                         
0x410x410x360x080x00// }
                         
0x020x010x020x040x02};// ~
void glcd_init(void)
{

   
GLCD_RST(1);
   
GLCD_EC(1);
   
GLCD_CS1C(1);
   
GLCD_CS2C(1);

   
GLCD_DIC(1);                     
   
glcd_writeByte(10xC0);   
   
glcd_writeByte(00xC0);   
   
glcd_writeByte(10x40);   
   
glcd_writeByte(00x40);
   
glcd_writeByte(10xB8); 
   
glcd_writeByte(00xB8);
   
   
glcd_writeByte(10x3F);
   
glcd_writeByte(00x3F);

   
glcd_fillScreen(0);         
}

void glcd_pixel(int xint yint color)
{
   
int data;
   
int chip 0

   if(
63
   {
      
-= 64;
      
chip 1;
   }

   
GLCD_DIC(1);                               
   
xx&0x7F;                                          
   
xx|0x40;                                          
   
glcd_writeByte(chipx);                             
   
glcd_writeByte(chip, (y/0xBF) | 0xB8);   
   
GLCD_DI(1); 
   
glcd_readByte(chip);                                 
   
data glcd_readByte(chip);

   if(
color == 1)
     
data=data|(1<<(y%8));      
   else                     
      
datadata&(~(1<<(y%8)));    
   
GLCD_DIC(1);    
   
glcd_writeByte(chipx);     
   
GLCD_DI(1);       
   
glcd_writeByte(chipdata); 
}

void glcd_line(int x1int y1int x2int y2int color)
{
   
signed int  xyaddxaddydxdy;
   
signed long P;
   
int i;
   if(
x2>x1)
     
dx=x2-x1;
   else
      
dx=x1-x2;
   if(
y2>y1)
      
dy=y2-y1;
   else
      
dy=y1-y2;
   
x1;
   
y1;

   if(
x1 x2)
      
addx = -1;
   else
      
addx 1;
   if(
y1 y2)
      
addy = -1;
   else
      
addy 1;

   if(
dx >= dy)
   {
      
2*dy dx;
      for(
i=0i<=dx; ++i)
      {
         
glcd_pixel(xycolor);

         if(
0)
         {
            
+= 2*dy;
            
+= addx;
         }
         else
         {
            
+= 2*dy 2*dx;
            
+= addx;
            
+= addy;
         }
      }
   }
   else
   {
      
2*dx dy;
      for(
i=0i<=dy; ++i)
      {
         
glcd_pixel(xycolor);

         if(
0)
         {
            
+= 2*dx;
            
+= addy;
         }
         else
         {
            
+= 2*dx 2*dy;
            
+= addx;
            
+= addy;
         }
      }
   }
}
void glcd_rect(int x1int y1int x2int y2int fillint color)
{
   if(
fill)
   {
      
int yminymax;
      
int xmin,xmax,i,j;
      if(
x1<x2)
      {
	
xmin=x1;
        
xmax=x2;
      }                         
      else
      {
	
xmin=x2;
        
xmax=x1;
      }
      if(
y1 y2)
      {
         
ymin y1;
         
ymax y2;
      }
      else
      {
         
ymin y2;
         
ymax y1;
      }
      for(
j=xmin;j<=xmax;++j)
      {
      for(
i=ymin;i<=ymax;++i
         {              
         
glcd_pixel(j,i,color);
         }
       }
    }
   else
   {
      
glcd_line(x1y1x2y1color);   
      
glcd_line(x1y2x2y2color);
      
glcd_line(x1y1x1y2color);
      
glcd_line(x2y1x2y2color);
   }
}

void glcd_bar(int x1int y1int x2int y2int widthint color)
{
   
signed int  xyaddxaddyj;
   
signed long Pdxdyc1c2;
   
int i;
   if(
x2>x1)
   
dx=x2-x1;
   else
   
dx=x1-x2;
   if(
y2>y1)
   
dy=y2-y1;
   else
   
dy=y1-y2;
   
   
x1;
   
y1;
   
c1 = -dx*x1 dy*y1;
   
c2 = -dx*x2 dy*y2;

   if(
x1 x2)
   {
      
addx = -1;
      
c1 = -dx*x2 dy*y2;
      
c2 = -dx*x1 dy*y1;
   }
   else
      
addx 1;
   if(
y1 y2)
   {
      
addy = -1;
      
c1 = -dx*x2 dy*y2;
      
c2 = -dx*x1 dy*y1;
   }
   else
      
addy 1;

   if(
dx >= dy)
   {
      
2*dy dx;

      for(
i=0i<=dx; ++i)
      {
         for(
j=-(width/2); j<width/2+width%2; ++j)
         {
            if(
dx*x+dy*(y+j)+c1 >= && dx*x+dy*(y+j)+c2 <=0)
               
glcd_pixel(xy+jcolor);
         }
         if(
0)
         {
            
+= 2*dy;
            
+= addx;
         }
         else
         {
            
+= 2*dy 2*dx;
            
+= addx;
            
+= addy;
         }
      }
   }
   else
   {
      
2*dx dy;

      for(
i=0i<=dy; ++i)
      {
         if(
0)
         {
            
+= 2*dx;
            
+= addy;
         }
         else
         {
            
+= 2*dx 2*dy;
            
+= addx;
            
+= addy;
         }
         for(
j=-(width/2); j<width/2+width%2; ++j)
         {
            if(
dx*x+dy*(y+j)+c1 >= && dx*x+dy*(y+j)+c2 <=0)
               
glcd_pixel(x+jycolor);
         }
      }
   }
}

void glcd_circle(int xint yint radiusint fillint color)
{
   
signed int abP;
   
0;
   
radius;
   
radius;

   do
   {
      if(
fill)
      {
         
glcd_line(x-ay+bx+ay+bcolor);
         
glcd_line(x-ay-bx+ay-bcolor);
         
glcd_line(x-by+ax+by+acolor);
         
glcd_line(x-by-ax+by-acolor);
      }
      else
      {
         
glcd_pixel(a+xb+ycolor);
         
glcd_pixel(b+xa+ycolor);
         
glcd_pixel(x-ab+ycolor);
         
glcd_pixel(x-ba+ycolor);
         
glcd_pixel(b+xy-acolor);
         
glcd_pixel(a+xy-bcolor);
         
glcd_pixel(x-ay-bcolor);
         
glcd_pixel(x-by-acolor);
      }

      if(
0)
         
P+= 2*a++;
      else
         
P+= 2*(a++ - b--);
    } while(
<= b);
}

void glcd_fillScreen(unsigned char color)
{
   
unsigned char ij;
   for(
08i++)
   {
      
GLCD_DIC(1);                   
      
glcd_writeByte(10x40);   
      
glcd_writeByte(00x40);
      
glcd_writeByte(10xB8); 
      
glcd_writeByte(00xB8);
      
GLCD_DI(1);                   
      for(
064j++)
      {
         
glcd_writeByte(10xFF*color);
         
glcd_writeByte(00xFF*color);
      }
   }
}
void glcd_text57(int xint ychartextptrint sizeint color)
{
   
int ijklm;                   
   
unsigned char pixelData[5];              

   for(
i=0textptr[i] != '\0'; ++i, ++x)
   {
      if(
textptr[i] < 'S'
         
memcpy(pixelDataTEXT[textptr[i]-' '], 5);
      else if(
textptr[i] <= '~'
         
memcpy(pixelDataTEXT2[textptr[i]-'S'], 5);
      else
         
memcpy(pixelDataTEXT[0], 5);  

      if(
x+5*size >= GLCD_WIDTH)       
      {
         
0;                         
         
+= 7*size 1;                
      }
      for(
j=0j<5; ++jx+=size)        
      {
         for(
k=0k<7*size; ++k)      
         {
            if((
pixelData[j]&(1<<k))>>k==1)
            {
               for(
l=0l<size; ++l)     
               {                       
                  for(
m=0m<size; ++m)
                  {
                     
glcd_pixel(x+my+k*size+lcolor); 
                  }
               }
            }
         }
      }
   }
}

void glcd_writeByte(int chipunsigned char data)
{
   if(
chip == 1)   
     { 
      
GLCD_CS1(1);
      
GLCD_CS2C(1);
     }
   else
      {
      
GLCD_CS2(1);
      
GLCD_CS1C(1);
      }
   
DelayUs(0,1);//****
   
GLCD_RWC(1);
   
DelayUs(0,1);//****    
   
LPC_GPIO0->FIOCLR=0xFFFFFFFF;
   
LPC_GPIO0->FIOSET=data<<15;          
   
GLCD_E(1);     
   
DelayUs(0,1);
   
GLCD_EC(1);
   
GLCD_CS1C(1);      
   
GLCD_CS2C(1);
}
unsigned char glcd_readByte(int chip)
{
   
unsigned char data
   
LPC_GPIO0->FIODIR=0x0000;
   
DelayUs(0,1);
   
GLCD_RW(1);
   if(
chip == 1)       
     { 
      
GLCD_CS1(1);
      
GLCD_CS2C(1);
     }
   else
      {
      
GLCD_CS2(1);
      
GLCD_CS1C(1);
      }
   
DelayUs(0,1);
   
GLCD_E(1);      
   
DelayUs(0,1);
   
data = ((LPC_GPIO0->FIOPIN>>15)&(0xFF));
   
GLCD_EC(1);
   
LPC_GPIO0->FIODIR=0xFFFFFFFF;
   
GLCD_CS1C(1);     
   
GLCD_CS2C(1);
   return (
data);         
}



lpc_glcd.h:


#define GLCD_WIDTH  128  
#define GLCD_HEIGTH 64

#define ON  1
#define OFF 0

#define YES 1
#define NO  0

#define GLCD_CS1(a) (LPC_GPIO1->FIOSET=a<<19)   // Chip Selection 1
#define GLCD_CS1C(a) (LPC_GPIO1->FIOCLR=a<<19)

#define GLCD_CS2(a) (LPC_GPIO1->FIOSET=a<<20)   // Chip Selection 2
#define GLCD_CS2C(a) (LPC_GPIO1->FIOCLR=a<<20)

#define GLCD_DI(a)  (LPC_GPIO1->FIOSET=a<<21)   // Data or Instruction input
#define GLCD_DIC(a)  (LPC_GPIO1->FIOCLR=a<<21)

#define GLCD_RW(a)  (LPC_GPIO1->FIOSET=a<<24)  // Read/Write
#define GLCD_RWC(a)  (LPC_GPIO1->FIOCLR=a<<24)

#define GLCD_E(a)   (LPC_GPIO1->FIOSET=a<<23)   // Enable
#define GLCD_EC(a)   (LPC_GPIO1->FIOCLR=a<<23)

#define GLCD_RST(a) (LPC_GPIO1->FIOSET=a<<25)
#define GLCD_RSTC(a) (LPC_GPIO1->FIOCLR=a<<25)   // Reset*/
	


extern void glcd_init(void);
extern void glcd_pixel(int x,int y,int color);
extern void glcd_line(int x1,int y1,int x2,int y2,int color);
extern void glcd_rect(int x1,int y1,int x2,int y2,int fill,int color);
extern void glcd_bar(int x1,int y1,int x2,int y2,int width,int color);
extern void glcd_circle(int x,int y,int radius,int fill,int color);
extern void glcd_text57(int x,int y,char *textptr,int size,int color);
extern void glcd_fillScreen(unsigned char color);
extern void glcd_writeByte(int chip,unsigned char data);
unsigned char glcd_readByte(int chip);



M_B

İmkanın sınırlarını görmek için imkansızı denemek lazım.                                                             Fatih Sultan Mehmet

buzkırıcı

Çok Teşekkürler. Çok güzel bir paylaşım..
İmza Atmayı bilmem Parnak Bassam olur mu?

Mujdat117

hocam tebrik ederim çok güzel bir uygulama olmuş insanın iştahını kabartıyo  :D
Ayinesi iştir kişinin lâfa bakılmaz.Şahsın görünür rütbe-i aklı eserinde

-Hasan-

Hocam süper süper süper olmuş.  :D Tebrikler, ARM için çok güzel bir örnek.

Murat Mert

Hasan Arm sende iyice ısınmaya başladı :D
mert07

-Hasan-

Alıntı yapılan: mert07 - 20 Kasım 2011, 18:54:43
Hasan Arm sende iyice ısınmaya başladı :D

Aynen öyle hocam.  :) Bir ARM öğrenme çılgınlığı aldı başını gidiyor bende.  :D

yamak

Alıntı yapılan: -Hasan- - 20 Kasım 2011, 20:30:00
Aynen öyle hocam.  :) Bir ARM öğrenme çılgınlığı aldı başını gidiyor bende.  :D
Hangi mcu yu kullanıyosunuz?

-Hasan-

Hocam yanlış anladınız galiba. ARM öğrenme hevesi demek istemiştim. ARM ' lar bayağı ilgimi çekiyor da o yüzden öyle söyledim.  :) STM32 kitlerini bekliyorum başlamak için. Ama siz bu işi çözmüşsünüz hocam. Tebrik ederim.

yamak

Yok ya benim de kendimi eksik hissettiğim bayaa yerler var. Öğrenecek daha çok şey var.Hem sen niye dert ediyon yaşın daha küçük benim yaşıma kadar neler öğrenirsin neler :)

Yasal Uyarı: Picproje.org sitemizde 5651 sayılı kanunun 8. maddesine ve T.C.Knın 125. maddesine göre tüm üyelerimiz yaptıkları paylaşımlardan kendileri sorumludur. Picproje.org hakkında yapılacak tüm hukuksal şikayetleri İletişim sayfamızdan bize bildirdikten en geç 3 (üç) iş günü içerisinde ilgili kanunlar ve yönetmelikler çerçevesinde tarafımızca incelenerek gereken işlemler yapılacak ve site yöneticilerimiz tarafından bilgi verilecektir.