#include "lpc23xx.h" #include "uart.h" #include "ssp.h" #include "l2f50126.h" extern int SDRAM_BASE_ADDR;// 0xa0000000 #define SDRAM_PERIOD 13.8 // 72MHz #define P2C(Period) (((Period 128 clk EMC_DYN_RFSH = P2C(SDRAM_REFRESH) >> 4; // Indicates SDRAM_REFRESH time between SDRAM refresh cycles. EMC_DYN_CTRL|=0x80; EMC_DYN_CTRL&=0xFFFFFEFF; //Issue SDRAM MODE command. //wtemp = *((volatile unsigned short *)(SDRAM_BASE_ADDR | 0x00023000)); // 8 burst, 2 CAS latency EMC_DYN_CTRL = 0x0000; //Issue SDRAM norm command ; //CLKOUT stop; All clock enables low EMC_DYN_CFG0|=0x80000; //Buffer enabled for accesses to DCS0 chip */ //} //int test_ram(void){ //unsigned int i; /* // 32 bits access for (i = 0; i < 0x200000; i+=sizeof(unsigned int)) { (*(unsigned int *)((unsigned int ) &SDRAM_BASE_ADDR+i)) = i; } for (i = 0; i < 0x200000; i+=sizeof(unsigned int )) { if (*(unsigned int *)((unsigned int )&SDRAM_BASE_ADDR+i) != i) { return(0); } } // 16 bits access for (i = 0; i < 0x10000; i+=sizeof(unsigned short)) { *(unsigned short*)((unsigned int)&SDRAM_BASE_ADDR+i) = i; } for (i = 0; i < 0x10000; i+=sizeof(unsigned short)) { if (*(unsigned short*)((unsigned int)&SDRAM_BASE_ADDR+i) != i) { return(0); }*/ // 8 bits access /*for ( i = 0; i < 0x200; i++) { (*(volatile unsigned long *)(SDRAM_BASE_ADDR + i)) = i; // *(unsigned char*)((unsigned int)&SDRAM_BASE_ADDR+i) = i; } for (i = 0; i < 0x200; i++) { if ((*(volatile unsigned long *)(SDRAM_BASE_ADDR + i)) != i) { return(i); } }*/ /* for (i = 0; i < 0x4000; i+=sizeof(unsigned int)) { *(unsigned int*)((unsigned int)&SDRAM_BASE_ADDR+i) = i; } for (i = 0; i < 0x4000; i+=sizeof(unsigned int)) { if (*(unsigned int*)((unsigned int)&SDRAM_BASE_ADDR+i) != i) { return(i); } }*/ // return( 1); //} //} void init_pll(void){ SCS|=(1<<5); /* Enable main OSC */ while(!(SCS&0x40)); /* Wait until main OSC is usable */ CLKSRCSEL = 0x1; PLLCON = 0; PLLFEED = 0xAA; PLLFEED = 0x55; // 4. Disable PLL PLLCON = 0; PLLFEED = 0xAA; PLLFEED = 0x55; // 5. Select source clock for PLL // 6. Set PLL settings 280.1664 MHz divider = 1 multiplier = 19 PLLCFG = (1<<16)|18; PLLFEED = 0xAA; PLLFEED = 0x55; // 7. Enable PLL PLLCON = 1; PLLFEED = 0xAA; PLLFEED = 0x55; // 8. Wait for the PLL to achieve lock while(!(PLLSTAT&(1<<26))); // 9. Set clk divider settings CCLKCFG = 4-1; // 1/4 Fpll - 70.0416 MHz //USBCLKCFG = 6-1; // 1/6 Fpll - 48 MHz // 10. Connect the PLL PLLCON = 3; PLLFEED = 0xAA; PLLFEED = 0x55; PCLKSEL0 = 0x55555555; //peripherals clock = 70.0416 MHz PCLKSEL1 = 0x55555555; MAMCR = 0x00; // Turn MAM off (default) MAMTIM = 0x04; // Set flash timing to 4 clock cycles MAMCR = 0x02; // Fully enable the Memory Accleration Module return; } int main(void){ //int i=0; init_pll(); init_uart0(115200); // init_ram(); SCS |= 1; //Enable FGPIO for port 0 and 1 init_ssp1(); lcd_init(); //fill_screen(RED); //displaystr("test",1,1); //FIO1DIR = (1<<5); while(1){ //sendint4_uart0(i); //send_uart0('a'); //sendstr_uart0("test"); //FIO1SET = (1<<5); //i++; sendbyte_ssp(0xffff); /*lcd_init(); fill_screen(RED); displaystr("test",1,1);*/ //FIO1CLR = (1<<5); // sendint4_uart0(0); } return 0; }