标签:
pll 锁相环,
倍频
串口工作核心图
//start.s AREA start_main,CODE, READONLY ENTRY IMPORT uart_test START B uart_test END //uart.c #define ULCON0 *((volatile unsigned int *)0XE2900000) #define UCON0 *((volatile unsigned int *)0XE2900004) #define UTRSTAT0 *((volatile unsigned int *)0XE2900010) #define UTXH0 *((volatile unsigned int *)0XE2900020) #define URXH0 *((volatile unsigned int *)0XE2900024) #define UBRDIV0 *((volatile unsigned int *)0XE2900028) #define UDIVSLOT0 *((volatile unsigned int *)0XE290002C) #define GPACON0 *((volatile unsigned int *)0XE0200000) void uart_init(void) { //串口管脚设置成功能态 GPACON0 = 0x22; //设置8 N 1 ULCON0 = 0X3; //设置轮询工作模式 UCON0 = 0X5; //设置波特率 UBRDIV0 = 34; UDIVSLOT0 = 0XDDDD; } char uart_getchar(void) { char ch; //如果有数据到达,状态寄存器第0位置1 //判断状态位是否为1,决定读接收缓冲寄存器,读到的值作为函数的返回值 while (!(UTRSTAT0 & 0x1)) ; ch = URXH0; return ch; } void uart_putchar(char ch) { //如果状态寄存器第1为置1,表示发送单元为空,可以发送数据 //把ch赋值到发送缓冲寄存器里,状态寄存器第1为置0, 自动发送,当发送完毕 while (!(UTRSTAT0 & 0X2)) ; UTXH0 = ch; } void uart_test(void) { char ch; uart_init(); uart_putchar('a'); uart_putchar('b'); uart_putchar('c'); //串口回显功能 while (1) { ch = uart_getchar(); uart_putchar(ch); } }
--------------------------------------------------
内存是总线设备,nandflash属于非总线设备。
#define NFCONF (*(volatile unsigned int *)0xB0E00000) #define NFCONT (*(volatile unsigned int *)0xB0E00004) #define NFCMMD (*(volatile unsigned int *)0xB0E00008) #define NFADDR (*(volatile unsigned int *)0xB0E0000C) #define NFDATA (*(volatile unsigned int *)0xB0E00010) #define NFSTAT (*(volatile unsigned int *)0xB0E00028) #define MP0_3CON (*(volatile unsigned int *)0xE0200320) #define PAGE_SIZE 2048 void nand_init(void) { //[15:12]TACLS = 1->(1) 1/133Mhz = 7.5ns //[11:8] TWRPH0 = 1->(1+7) 7.5ns*2 = 15ns //[7:4] TWRPH1 = 1->(1+1) 7.5ms *2 = 15ns NFCONF |= 1<<2 | 1<< 8 | 1<< 4; //AdrCycle [1]1=5 address cycle NFCONF |= 1<<1; //MODE [0] NAND Flash controller operating node // 0=disable nand flash controller // *1 = enable nand flash controller NFCONT |= 1<<0; //Reg_nCE0 [1] nandflash memort nRCS[0] signal control // *0 = force nRCS[0] to low (enable chip select) // 1 = force nRCS[0] to high(disable chip select) NFCONT &= ~(1<<1); //GPIO functional mux setting // 0010 = NF_xxx MP0_3CON = 0X22222222; return ; } void nand_read_id(char id[]) { int i; //write read_id cmd 90th NFCMMD = 0X90; //write address 00h NFADDR = 0x00; for(i=0; i<5; i++) { id[i] = NFDATA; } return ; } void nand_read_page(int addr, char buf[]) { int i; char tmp; //write read_page cmd 00h NFCMMD = 0X00; //write 5 address NFADDR = (addr >> 0) & 0xFF; NFADDR = (addr >> 8) & 0x7; NFADDR = (addr >> 11) & 0xFF; NFADDR = (addr >> 19) & 0xFF; NFADDR = (addr >> 27) & 0x1; //write read_page cmd 30h NFCMMD = 0X30; //wait for R/nB -->ready while( (NFSTAT &(1<<0))==0 ) ; //read data 2048 bytes for(i=0; i<PAGE_SIZE; i++) { buf[i] = NFDATA; } for (i=0; i<64; i++) { tmp = NFDATA; } return ; } void nand_read(int nand_addr, char *sdram_addr, int size) { int pages = (size -1)/PAGE_SIZE + 1; int i; for (i=0; i<pages; i++) { nand_read_page(nand_addr + i*PAGE_SIZE, sdram_addr + i*PAGE_SIZE); } }
bootloader功能介绍/时钟初始化设置/串口工作原理/内存工作原理/NandFlash工作原理
标签:
原文地址:http://blog.csdn.net/waldmer/article/details/44993647