Keil Carm LPC2148 Proje_1 250ms Geciktirme

Başlatan ahmet2004, 24 Mayıs 2009, 00:35:37

ahmet2004

//--------------------------------------------------------------------//
// Program		: 250 miliSaniye Led Aç Kapa   
// Description: LED aç kapa Pin:P0.22
// Frequency	: Xtal 12 MHz at PLL 5x(CCLK = 60 MHz),PCLK = 60 MHz 
// C compiler	: Keil CARM Compiler
// Hazirlayan : By ahmet2004
//--------------------------------------------------------------------//
#include "lpc214x.h" 

#define LED_AC IOCLR0  = 0x00400000
#define LED_KAPA IOSET0 = 0x00400000

void ayarlar() 
{   
	PLL0CFG =0x24;
	PLL0FEED=0xAA;	
	PLL0FEED=0x55; 	
      
	PLL0CON =0x01;
	PLL0FEED=0xAA;
	PLL0FEED=0x55;

	while(!(PLL0STAT & 0x400)) ;
  
	PLL0CON=0x3;
	PLL0FEED=0xAA;
	PLL0FEED=0x55;
  
	MAMCR=0x2;
	MAMTIM=0x4;
  
	VPBDIV=0x02;
}

//---------------------------------------------------------------//
//------------------------ Geciktirme ---------------------------//
//---------------------------------------------------------------//
void milisaniye(long ms)
{
	long i,j;
	for (i = 0; i < ms; i++ )
	for (j = 0; j < 7460; j++ );
}

//--------------------------------------------------------------//
//----------------------- Ana Program --------------------------//
//--------------------------------------------------------------//
int main(void) 
{
	ayarlar();	
  MEMMAP = 0x01;
	IODIR1 = 0x00FF0000;
	IOCLR1 = 0x00FF0000;
    
	PINSEL0 = 0x00000000;
	PINSEL1 = 0x00000000;
  VPBDIV  = 0x00000001;
	IODIR0 |= 0x00600000;
    
  while (1) 
	{ 
        LED_KAPA;
        milisaniye(250);
        LED_AC;
        milisaniye(250);
	}
}