Keil5 平台 S3C2440裸机程序开发-----UART

目录

前言

一、时钟频率

二、代码

main.c

uart.c

uart.h

led.c

led.h

S3C2440.h

三、编译,烧录,打开串口助手,接收到数据。


前言

本博文介绍mini2440开发板,在keil5平台上进行UART串口开发的一些基本配置。


一、时钟频率

开发板接的是12MHz晶振,即Fin=12MHz,UART时钟源选择PCLK。以下是根据自带的S3C2440.s启动文件配置来计算PCLK,具体的时钟寄存器配置请参考芯片手册。

打开S3C2440.s,点击Configuration Wizard。

Keil5 平台 S3C2440裸机程序开发-----UART_第1张图片

 MPLL计算公式,MPLL=(2*m*Fin)/(p*2^s),即

FCLK=(2*0x004B*12MHz)/(0x03*2^0x01)=(2*75*12MHz)/(3*2^1)=300MHz

CLKDIVN分频比为,FCLK:HCLK:PCLK=1:3:6

PCLK=FCLK/6=300MHz/6=50MHz

二、代码

main.c

#include 
#include "led.h"
#include "uart.h"


void __use_two_region_memory(void)
{
	
}

int __main()
{

	UART0_Init();
	LED_Init();
	
	LED1_ON();

	while(1)
	{
		UART0_putc('c');
		delay(1000000);

	}

}

uart.c

#include 

void UART0_Init(void)
{

	//设置GPH端口UART0模式,使能内部上拉
	GPHCON &= ~((3<<4)|(3<<6));
	GPHCON |= (2<<4)|(2<<6);		//GPH2-TXD, GPH3-RXD
	GPHUP &= ~((1<<2)|(1<<3));		//GPH2,GPH3 使能上拉
	
	//UART0
	ULCON0=0X03;/*8位数据位,无校验,1个停止位*/
	
	UCON0=0X005;/*PCLK时钟源50MHz,正常模式,中断/查询模式*/
	
	UFCON0=0X00;/*7:0设置FIFO寄存器,默认0*/
	
	UMCON0=0X00;/*7:0设置modem寄存器,默认0*/
	
	/* 
	设置波特率
	BRDIVn = (int)( UART clock / ( buad rate x 16) ) –1
	UART clock =PCLK= 50M
	UBRDIVn = (int)( 50000000 / ( 115200 x 16) ) –1 = 26
	*/
	UBRDIV0=26;
}


void UART0_putc(unsigned char c)
{

	while(!(UTRSTAT0&(1<<2)));
	UTXH0=c;

}

unsigned char UART0_getc(void)
{
	while(!(UTRSTAT0 & (1<<0)));
	return URXH0;
}

uart.h

#ifndef __UART_H
#define __UART_H

void UART0_Init(void);
void UART0_putc(unsigned char c);
unsigned char UART0_getc(void);

#endif

led.c

#include 

//开发板4个LED初始化
void LED_Init(void)
{
	GPBCON = ((GPBCON|0X15400)&0X3D57FF);
	GPBDAT = GPBDAT|0X1E0;
}

//打开开发板的LED1
void LED1_ON(void)
{
  GPBDAT = GPBDAT&0X7DF;
}

//打开开发板的LED4
void LED4_ON(void)
{
	GPBDAT = GPBDAT&0X6FF;
}
//关闭开发板的LED4
void LED4_OFF(void)
{
	GPBDAT = GPBDAT|0X100;
}

void delay(int temp)
{
	while(temp)temp--;
}

led.h

#ifndef __LED_H
#define __LED_H

void LED_Init(void);
void LED1_ON(void);
void LED4_ON(void);
void LED4_OFF(void);

void delay(int temp);

#endif

S3C2440.h

/***********************************************************************/
/*  This file is part of the uVision/ARM development tools             */
/*  Copyright KEIL - An ARM Company 2002-2007                          */
/***********************************************************************/
/*                                                                     */
/*  S3C2440.H:  Header file for Samsung S3C2440                        */
/*                                                                     */
/***********************************************************************/

#ifndef __S3C2440_H
#define __S3C2440_H

// Memory Controllers 
#define BWSCON               (*(volatile unsigned long *) 0x48000000)
#define BANKCON0             (*(volatile unsigned long *) 0x48000004)
#define BANKCON1             (*(volatile unsigned long *) 0x48000008)
#define BANKCON2             (*(volatile unsigned long *) 0x4800000C)
#define BANKCON3             (*(volatile unsigned long *) 0x48000010)
#define BANKCON4             (*(volatile unsigned long *) 0x48000014)
#define BANKCON5             (*(volatile unsigned long *) 0x48000018)
#define BANKCON6             (*(volatile unsigned long *) 0x4800001C)
#define BANKCON7             (*(volatile unsigned long *) 0x48000020)
#define REFRESH              (*(volatile unsigned long *) 0x48000024)
#define BANKSIZE             (*(volatile unsigned long *) 0x48000028)
#define MRSRB6               (*(volatile unsigned long *) 0x4800002C)
#define MRSRB7               (*(volatile unsigned long *) 0x48000030)

// USB Host Controller
#define HcRevision           (*(volatile unsigned long *) 0x49000000)
#define HcControl            (*(volatile unsigned long *) 0x49000004)
#define HcCommonStatus       (*(volatile unsigned long *) 0x49000008)
#define HcInterruptStatus    (*(volatile unsigned long *) 0x4900000C)
#define HcInterruptEnable    (*(volatile unsigned long *) 0x49000010)
#define HcInterruptDisable   (*(volatile unsigned long *) 0x49000014)
#define HcHCCA               (*(volatile unsigned long *) 0x49000018)
#define HcPeriodCuttentED    (*(volatile unsigned long *) 0x4900001C)
#define HcControlHeadED      (*(volatile unsigned long *) 0x49000020)
#define HcControlCurrentED   (*(volatile unsigned long *) 0x49000024)
#define HcBulkHeadED         (*(volatile unsigned long *) 0x49000028)
#define HcBulkCurrentED      (*(volatile unsigned long *) 0x4900002C)
#define HcDoneHead           (*(volatile unsigned long *) 0x49000030)
#define HcRmInterval         (*(volatile unsigned long *) 0x49000034)
#define HcFmRemaining        (*(volatile unsigned long *) 0x49000038)
#define HcFmNumber           (*(volatile unsigned long *) 0x4900003C)
#define HcPeriodicStart      (*(volatile unsigned long *) 0x49000040)
#define HcLSTreshold         (*(volatile unsigned long *) 0x49000044)
#define HcRhDescriptorA      (*(volatile unsigned long *) 0x49000048)
#define HcRhDescriptorB      (*(volatile unsigned long *) 0x4900004C)
#define HcRhStatus           (*(volatile unsigned long *) 0x49000050)
#define HcRhPortStatus1      (*(volatile unsigned long *) 0x49000054)
#define HcRhPortStatus2      (*(volatile unsigned long *) 0x49000058)

// Interrupt Controller
#define SRCPND               (*(volatile unsigned long *) 0x4A000000)
#define INTMOD               (*(volatile unsigned long *) 0x4A000004)
#define INTMSK               (*(volatile unsigned long *) 0x4A000008)
#define PRIORITY             (*(volatile unsigned long *) 0x4A00000C)
#define INTPND               (*(volatile unsigned long *) 0x4A000010)
#define INTOFFSET            (*(volatile unsigned long *) 0x4A000014)
#define SUBSRCPND            (*(volatile unsigned long *) 0x4A000018)
#define INTSUBMSK            (*(volatile unsigned long *) 0x4A00001C)

// DMA
#define DISRC0               (*(volatile unsigned long *) 0x4B000000)
#define DISRCC0              (*(volatile unsigned long *) 0x4B000004)
#define DIDST0               (*(volatile unsigned long *) 0x4B000008)
#define DIDSTC0              (*(volatile unsigned long *) 0x4B00000C)
#define DCON0                (*(volatile unsigned long *) 0x4B000010)
#define DSTAT0               (*(volatile unsigned long *) 0x4B000014)
#define DCSRC0               (*(volatile unsigned long *) 0x4B000018)
#define DCDST0               (*(volatile unsigned long *) 0x4B00001C)
#define DMASKTRIG0           (*(volatile unsigned long *) 0x4B000020)

#define DISRC1               (*(volatile unsigned long *) 0x4B000040)
#define DISRCC1              (*(volatile unsigned long *) 0x4B000044)
#define DIDST1               (*(volatile unsigned long *) 0x4B000048)
#define DIDSTC1              (*(volatile unsigned long *) 0x4B00004C)
#define DCON1                (*(volatile unsigned long *) 0x4B000050)
#define DSTAT1               (*(volatile unsigned long *) 0x4B000054)
#define DCSRC1               (*(volatile unsigned long *) 0x4B000058)
#define DCDST1               (*(volatile unsigned long *) 0x4B00005C)
#define DMASKTRIG1           (*(volatile unsigned long *) 0x4B000060)

#define DISRC2               (*(volatile unsigned long *) 0x4B000080)
#define DISRCC2              (*(volatile unsigned long *) 0x4B000084)
#define DIDST2               (*(volatile unsigned long *) 0x4B000088)
#define DIDSTC2              (*(volatile unsigned long *) 0x4B00008C)
#define DCON2                (*(volatile unsigned long *) 0x4B000090)
#define DSTAT2               (*(volatile unsigned long *) 0x4B000094)
#define DCSRC2               (*(volatile unsigned long *) 0x4B000098)
#define DCDST2               (*(volatile unsigned long *) 0x4B00009C)
#define DMASKTRIG2           (*(volatile unsigned long *) 0x4B0000a0)

#define DISRC3               (*(volatile unsigned long *) 0x4B0000C0)
#define DISRCC3              (*(volatile unsigned long *) 0x4B0000C4)
#define DIDST3               (*(volatile unsigned long *) 0x4B0000C8)
#define DIDSTC3              (*(volatile unsigned long *) 0x4B0000CC)
#define DCON3                (*(volatile unsigned long *) 0x4B0000D0)
#define DSTAT3               (*(volatile unsigned long *) 0x4B0000D4)
#define DCSRC3               (*(volatile unsigned long *) 0x4B0000D8)
#define DCDST3               (*(volatile unsigned long *) 0x4B0000DC)
#define DMASKTRIG3           (*(volatile unsigned long *) 0x4B0000E0)


// Clock & Power Management
#define LOCKTIME             (*(volatile unsigned long *) 0x4C000000)
#define MPLLCON              (*(volatile unsigned long *) 0x4C000004)
#define UPLLCON              (*(volatile unsigned long *) 0x4C000008)
#define CLKCON               (*(volatile unsigned long *) 0x4C00000C)
#define CLKSLOW              (*(volatile unsigned long *) 0x4C000010)
#define CLKDIVN              (*(volatile unsigned long *) 0x4C000014)
#define CAMDIVN              (*(volatile unsigned long *) 0x4C000018)

// LCD Controller
#define LCDCON1              (*(volatile unsigned long *) 0x4D000000)
#define LCDCON2              (*(volatile unsigned long *) 0x4D000004)
#define LCDCON3              (*(volatile unsigned long *) 0x4D000008)
#define LCDCON4              (*(volatile unsigned long *) 0x4D00000C)
#define LCDCON5              (*(volatile unsigned long *) 0x4D000010)
#define LCDSADDR1            (*(volatile unsigned long *) 0x4D000014)
#define LCDSADDR2            (*(volatile unsigned long *) 0x4D000018)
#define LCDSADDR3            (*(volatile unsigned long *) 0x4D00001C)
#define REDLUT               (*(volatile unsigned long *) 0x4D000020)
#define GREENLUT             (*(volatile unsigned long *) 0x4D000024)
#define BLUELUT              (*(volatile unsigned long *) 0x4D000028)
#define DITHMODE             (*(volatile unsigned long *) 0x4D00004C)
#define TPAL                 (*(volatile unsigned long *) 0x4D000050)
#define LCDINTPND            (*(volatile unsigned long *) 0x4D000054)
#define LCDSRCPND            (*(volatile unsigned long *) 0x4D000058)
#define LCDINTMSK            (*(volatile unsigned long *) 0x4D00005C)
#define LPCSEL               (*(volatile unsigned long *) 0x4D000060)
#define PALETTE               0x4D000400

// NAND flash
#define NFCONF               (*(volatile unsigned long *) 0x4E000000)
#define NFCONT               (*(volatile unsigned long *) 0x4E000004)
#define NFCMD                (*(volatile unsigned long *) 0x4E000008)
#define NFADDR               (*(volatile unsigned long *) 0x4E00000C)
#define NFDATA               (*(volatile unsigned long *) 0x4E000010)
#define NFMECCD0             (*(volatile unsigned long *) 0x4E000014)
#define NFMECCD1             (*(volatile unsigned long *) 0x4E000018)
#define NFSECCD              (*(volatile unsigned long *) 0x4E00001C)
#define NFSTAT               (*(volatile unsigned long *) 0x4E000020)
#define NFESTAT0             (*(volatile unsigned long *) 0x4E000024)
#define NFESTAT1             (*(volatile unsigned long *) 0x4E000028)
#define NFMECC0              (*(volatile unsigned long *) 0x4E00002C)
#define NFMECC1              (*(volatile unsigned long *) 0x4E000030)
#define NFSECC               (*(volatile unsigned long *) 0x4E000034)
#define NFSBLK               (*(volatile unsigned long *) 0x4E000038)
#define NFEBLK               (*(volatile unsigned long *) 0x4E00003C)

// Camera Interface
#define CISRCFMT             (*(volatile unsigned long *) 0x4F000000)
#define CIWDOFST             (*(volatile unsigned long *) 0x4F000004)
#define CIGCTRL              (*(volatile unsigned long *) 0x4F000008)
#define CICOYSA1             (*(volatile unsigned long *) 0x4F000018)
#define CICOYSA2             (*(volatile unsigned long *) 0x4F00001C)
#define CICOYSA3             (*(volatile unsigned long *) 0x4F000020)
#define CICOYSA4             (*(volatile unsigned long *) 0x4F000024)
#define CICOCBSA1            (*(volatile unsigned long *) 0x4F000028)
#define CICOCBSA2            (*(volatile unsigned long *) 0x4F00002C)
#define CICOCBSA3            (*(volatile unsigned long *) 0x4F000030)
#define CICOCBSA4            (*(volatile unsigned long *) 0x4F000034)
#define CICORSA1             (*(volatile unsigned long *) 0x4F000038)
#define CICORSA2             (*(volatile unsigned long *) 0x4F00003C)
#define CICORSA3             (*(volatile unsigned long *) 0x4F000040)
#define CICORSA4             (*(volatile unsigned long *) 0x4F000044)
#define CICOTRGFMT           (*(volatile unsigned long *) 0x4F000048)
#define CICOCTRL             (*(volatile unsigned long *) 0x4F00004C)
#define CICOSCPRERATIO       (*(volatile unsigned long *) 0x4F000050)
#define CICOSCPREDST         (*(volatile unsigned long *) 0x4F000054)
#define CICOSCCTRL           (*(volatile unsigned long *) 0x4F000058)
#define CICOTAREA            (*(volatile unsigned long *) 0x4F00005C)
#define CICOSTATUS           (*(volatile unsigned long *) 0x4F000064)
#define CIPRCLRSA1           (*(volatile unsigned long *) 0x4F00006C)
#define CIPRCLRSA2           (*(volatile unsigned long *) 0x4F000070)
#define CIPRCLRSA3           (*(volatile unsigned long *) 0x4F000074)
#define CIPRCLRSA4           (*(volatile unsigned long *) 0x4F000078)
#define CIPRTRGFMT           (*(volatile unsigned long *) 0x4F00007C)
#define CIPRCTRL             (*(volatile unsigned long *) 0x4F000080)
#define CIPRSCPRERATIO       (*(volatile unsigned long *) 0x4F000084)
#define CIPRSCPREDST         (*(volatile unsigned long *) 0x4F000088)
#define CIPRSCCTRL           (*(volatile unsigned long *) 0x4F00008C)
#define CIPRTAREA            (*(volatile unsigned long *) 0x4F000090)
#define CIPRSTATUS           (*(volatile unsigned long *) 0x4F000098)
#define CIIMGCPT             (*(volatile unsigned long *) 0x4F0000A0)


// UART
#define ULCON0               (*(volatile unsigned long *) 0x50000000)
#define UCON0                (*(volatile unsigned long *) 0x50000004)
#define UFCON0               (*(volatile unsigned long *) 0x50000008)
#define UMCON0               (*(volatile unsigned long *) 0x5000000C)
#define UTRSTAT0             (*(volatile unsigned long *) 0x50000010)
#define UERSTAT0             (*(volatile unsigned long *) 0x50000014)
#define UFSTAT0              (*(volatile unsigned long *) 0x50000018)
#define UMSTAT0              (*(volatile unsigned long *) 0x5000001C)
#define UTXH0                (*(volatile unsigned char *) 0x50000020)
#define URXH0                (*(volatile unsigned char *) 0x50000024)
#define UBRDIV0              (*(volatile unsigned long *) 0x50000028)

#define ULCON1               (*(volatile unsigned long *) 0x50004000)
#define UCON1                (*(volatile unsigned long *) 0x50004004)
#define UFCON1               (*(volatile unsigned long *) 0x50004008)
#define UMCON1               (*(volatile unsigned long *) 0x5000400C)
#define UTRSTAT1             (*(volatile unsigned long *) 0x50004010)
#define UERSTAT1             (*(volatile unsigned long *) 0x50004014)
#define UFSTAT1              (*(volatile unsigned long *) 0x50004018)
#define UMSTAT1              (*(volatile unsigned long *) 0x5000401C)
#define UTXH1                (*(volatile unsigned char *) 0x50004020)
#define URXH1                (*(volatile unsigned char *) 0x50004024)
#define UBRDIV1              (*(volatile unsigned long *) 0x50004028)

#define ULCON2               (*(volatile unsigned long *) 0x50008000)
#define UCON2                (*(volatile unsigned long *) 0x50008004)
#define UFCON2               (*(volatile unsigned long *) 0x50008008)
#define UMCON2               (*(volatile unsigned long *) 0x5000800C)
#define UTRSTAT2             (*(volatile unsigned long *) 0x50008010)
#define UERSTAT2             (*(volatile unsigned long *) 0x50008014)
#define UFSTAT2              (*(volatile unsigned long *) 0x50008018)
#define UTXH2                (*(volatile unsigned char *) 0x50008020)
#define URXH2                (*(volatile unsigned char *) 0x50008024)
#define UBRDIV2              (*(volatile unsigned long *) 0x50008028)

#ifdef __BIG_ENDIAN
#undef  UTXH0
#define UTXH0                (*(volatile unsigned char *) 0x50000023)
#undef  URXH0
#define URXH0                (*(volatile unsigned char *) 0x50000027)
#undef  UTXH1
#define UTXH1                (*(volatile unsigned char *) 0x50004023)
#undef  URXH1
#define URXH1                (*(volatile unsigned char *) 0x50004027)
#undef  UTXH2
#define UTXH2                (*(volatile unsigned char *) 0x50008023)
#undef  URXH2
#define URXH2                (*(volatile unsigned char *) 0x50008027)
#endif

// PWM Timer
#define TCFG0                (*(volatile unsigned long *) 0x51000000)
#define TCFG1                (*(volatile unsigned long *) 0x51000004)
#define TCON                 (*(volatile unsigned long *) 0x51000008)
#define TCNTB0               (*(volatile unsigned long *) 0x5100000C)
#define TCMPB0               (*(volatile unsigned long *) 0x51000010)
#define TCNTO0               (*(volatile unsigned long *) 0x51000014)
#define TCNTB1               (*(volatile unsigned long *) 0x51000018)
#define TCMPB1               (*(volatile unsigned long *) 0x5100001C)
#define TCNTO1               (*(volatile unsigned long *) 0x51000020)
#define TCNTB2               (*(volatile unsigned long *) 0x51000024)
#define TCMPB2               (*(volatile unsigned long *) 0x51000028)
#define TCNTO2               (*(volatile unsigned long *) 0x5100002C)
#define TCNTB3               (*(volatile unsigned long *) 0x51000030)
#define TCMPB3               (*(volatile unsigned long *) 0x51000034)
#define TCNTO3               (*(volatile unsigned long *) 0x51000038)
#define TCNTB4               (*(volatile unsigned long *) 0x5100003C)
#define TCNTO4               (*(volatile unsigned long *) 0x51000040)


// USB Device
#ifdef  __BIG_ENDIAN
#define FUNC_ADDR_REG        (*(volatile unsigned char *) 0x52000143)
#define PWR_REG              (*(volatile unsigned char *) 0x52000147)
#define EP_INT_REG           (*(volatile unsigned char *) 0x5200014B)
#define USB_INT_REG          (*(volatile unsigned char *) 0x5200015B)
#define EP_INT_EN_REG        (*(volatile unsigned char *) 0x5200015F)
#define USB_INT_EN_REG       (*(volatile unsigned char *) 0x5200016F)
#define FRAME_NUM1_REG       (*(volatile unsigned char *) 0x52000173)
#define FRAME_NUM2_REG       (*(volatile unsigned char *) 0x52000177)
#define INDEX_REG            (*(volatile unsigned char *) 0x5200017B)
#define MAXP_REG             (*(volatile unsigned char *) 0x52000183)
#define EP0_CSR              (*(volatile unsigned char *) 0x52000187)
#define IN_CSR1_REG          (*(volatile unsigned char *) 0x52000187)
#define IN_CSR2_REG          (*(volatile unsigned char *) 0x5200018B)
#define OUT_CSR1_REG         (*(volatile unsigned char *) 0x52000193)
#define OUT_CSR2_REG         (*(volatile unsigned char *) 0x52000197)
#define OUT_FIFO_CNT1_REG    (*(volatile unsigned char *) 0x5200019B)
#define OUT_FIFO_CNT2_REG    (*(volatile unsigned char *) 0x5200019F)
#define EP0_FIFO             (*(volatile unsigned char *) 0x520001C3)
#define EP1_FIFO             (*(volatile unsigned char *) 0x520001C7)
#define EP2_FIFO             (*(volatile unsigned char *) 0x520001CF)
#define EP3_FIFO             (*(volatile unsigned char *) 0x520001CF)
#define EP4_FIFO             (*(volatile unsigned char *) 0x520001D3)
#define EP1_DMA_CON          (*(volatile unsigned char *) 0x52000203)
#define EP1_DMA_UNIT         (*(volatile unsigned char *) 0x52000207)
#define EP1_DMA_FIFO         (*(volatile unsigned char *) 0x5200020B)
#define EP1_DMA_TTC_L        (*(volatile unsigned char *) 0x5200020F)
#define EP1_DMA_TTC_M        (*(volatile unsigned char *) 0x52000213)
#define EP1_DMA_TTC_H        (*(volatile unsigned char *) 0x52000217)
#define EP2_DMA_CON          (*(volatile unsigned char *) 0x5200021B)
#define EP2_DMA_UNIT         (*(volatile unsigned char *) 0x5200021F)
#define EP2_DMA_FIFO         (*(volatile unsigned char *) 0x52000223)
#define EP2_DMA_TTC_L        (*(volatile unsigned char *) 0x52000227)
#define EP2_DMA_TTC_M        (*(volatile unsigned char *) 0x5200022B)
#define EP2_DMA_TTC_H        (*(volatile unsigned char *) 0x5200022F)
#define EP3_DMA_CON          (*(volatile unsigned char *) 0x52000243)
#define EP3_DMA_UNIT         (*(volatile unsigned char *) 0x52000247)
#define EP3_DMA_FIFO         (*(volatile unsigned char *) 0x5200024B)
#define EP3_DMA_TTC_L        (*(volatile unsigned char *) 0x5200024F)
#define EP3_DMA_TTC_M        (*(volatile unsigned char *) 0x52000253)
#define EP3_DMA_TTC_H        (*(volatile unsigned char *) 0x52000257)
#define EP4_DMA_CON          (*(volatile unsigned char *) 0x5200025B)
#define EP4_DMA_UNIT         (*(volatile unsigned char *) 0x5200025F)
#define EP4_DMA_FIFO         (*(volatile unsigned char *) 0x52000263)
#define EP4_DMA_TTC_L        (*(volatile unsigned char *) 0x52000267)
#define EP4_DMA_TTC_M        (*(volatile unsigned char *) 0x5200026B)
#define EP4_DMA_TTC_H        (*(volatile unsigned char *) 0x5200026F)

#else   // Little Endian
#define FUNC_ADDR_REG        (*(volatile unsigned char *) 0x52000140)
#define PWR_REG              (*(volatile unsigned char *) 0x52000144)
#define EP_INT_REG           (*(volatile unsigned char *) 0x52000148)
#define USB_INT_REG          (*(volatile unsigned char *) 0x52000158)
#define EP_INT_EN_REG        (*(volatile unsigned char *) 0x5200015C)
#define USB_INT_EN_REG       (*(volatile unsigned char *) 0x5200016C)
#define FRAME_NUM1_REG       (*(volatile unsigned char *) 0x52000170)
#define FRAME_NUM2_REG       (*(volatile unsigned char *) 0x52000174)
#define INDEX_REG            (*(volatile unsigned char *) 0x52000178)
#define MAXP_REG             (*(volatile unsigned char *) 0x52000180)
#define EP0_CSR              (*(volatile unsigned char *) 0x52000184)
#define IN_CSR1_REG          (*(volatile unsigned char *) 0x52000184)
#define IN_CSR2_REG          (*(volatile unsigned char *) 0x52000188)
#define OUT_CSR1_REG         (*(volatile unsigned char *) 0x52000190)
#define OUT_CSR2_REG         (*(volatile unsigned char *) 0x52000194)
#define OUT_FIFO_CNT1_REG    (*(volatile unsigned char *) 0x52000198)
#define OUT_FIFO_CNT2_REG    (*(volatile unsigned char *) 0x5200019C)
#define EP0_FIFO             (*(volatile unsigned char *) 0x520001C0)
#define EP1_FIFO             (*(volatile unsigned char *) 0x520001C4)
#define EP2_FIFO             (*(volatile unsigned char *) 0x520001C8)
#define EP3_FIFO             (*(volatile unsigned char *) 0x520001CC)
#define EP4_FIFO             (*(volatile unsigned char *) 0x520001D0)
#define EP1_DMA_CON          (*(volatile unsigned char *) 0x52000200)
#define EP1_DMA_UNIT         (*(volatile unsigned char *) 0x52000204)
#define EP1_DMA_FIFO         (*(volatile unsigned char *) 0x52000208)
#define EP1_DMA_TTC_L        (*(volatile unsigned char *) 0x5200020C)
#define EP1_DMA_TTC_M        (*(volatile unsigned char *) 0x52000210)
#define EP1_DMA_TTC_H        (*(volatile unsigned char *) 0x52000214)
#define EP2_DMA_CON          (*(volatile unsigned char *) 0x52000218)
#define EP2_DMA_UNIT         (*(volatile unsigned char *) 0x5200021C)
#define EP2_DMA_FIFO         (*(volatile unsigned char *) 0x52000220)
#define EP2_DMA_TTC_L        (*(volatile unsigned char *) 0x52000224)
#define EP2_DMA_TTC_M        (*(volatile unsigned char *) 0x52000228)
#define EP2_DMA_TTC_H        (*(volatile unsigned char *) 0x5200022C)
#define EP3_DMA_CON          (*(volatile unsigned char *) 0x52000240)
#define EP3_DMA_UNIT         (*(volatile unsigned char *) 0x52000244)
#define EP3_DMA_FIFO         (*(volatile unsigned char *) 0x52000248)
#define EP3_DMA_TTC_L        (*(volatile unsigned char *) 0x5200024C)
#define EP3_DMA_TTC_M        (*(volatile unsigned char *) 0x52000250)
#define EP3_DMA_TTC_H        (*(volatile unsigned char *) 0x52000254)
#define EP4_DMA_CON          (*(volatile unsigned char *) 0x52000258)
#define EP4_DMA_UNIT         (*(volatile unsigned char *) 0x5200025C)
#define EP4_DMA_FIFO         (*(volatile unsigned char *) 0x52000260)
#define EP4_DMA_TTC_L        (*(volatile unsigned char *) 0x52000264)
#define EP4_DMA_TTC_M        (*(volatile unsigned char *) 0x52000268)
#define EP4_DMA_TTC_H        (*(volatile unsigned char *) 0x5200026C)
#endif

// Watchdog Timer
#define WTCON                (*(volatile unsigned long *) 0x53000000)
#define WTDAT                (*(volatile unsigned long *) 0x53000004)
#define WTCNT                (*(volatile unsigned long *) 0x53000008)

// IIC
#define IICCON               (*(volatile unsigned long *) 0x54000000)
#define IICSTAT              (*(volatile unsigned long *) 0x54000004)
#define IICADD               (*(volatile unsigned long *) 0x54000008)
#define IICDS                (*(volatile unsigned long *) 0x5400000C)
#define IICLC                (*(volatile unsigned long *) 0x54000010)

// IIS
#define IISCON               (*(volatile unsigned long *) 0x55000000)
#define IISMOD               (*(volatile unsigned long *) 0x55000004)
#define IISPSR               (*(volatile unsigned long *) 0x55000008)
#define IISFCON              (*(volatile unsigned long *) 0x5500000C)
#define IISFIFO              (*(volatile unsigned short*) 0x55000010)

#ifdef __BIG_ENDIAN
#undef  IISFIFO
#define IISFIFO              (*(volatile unsigned short*) 0x55000012)
#endif

// I/O port 
#define GPACON               (*(volatile unsigned long *) 0x56000000)
#define GPADAT               (*(volatile unsigned long *) 0x56000004)
                       
#define GPBCON               (*(volatile unsigned long *) 0x56000010)
#define GPBDAT               (*(volatile unsigned long *) 0x56000014)
#define GPBUP                (*(volatile unsigned long *) 0x56000018)
                       
#define GPCCON               (*(volatile unsigned long *) 0x56000020)
#define GPCDAT               (*(volatile unsigned long *) 0x56000024)
#define GPCUP                (*(volatile unsigned long *) 0x56000028)
                       
#define GPDCON               (*(volatile unsigned long *) 0x56000030)
#define GPDDAT               (*(volatile unsigned long *) 0x56000034)
#define GPDUP                (*(volatile unsigned long *) 0x56000038)
                       
#define GPECON               (*(volatile unsigned long *) 0x56000040)
#define GPEDAT               (*(volatile unsigned long *) 0x56000044)
#define GPEUP                (*(volatile unsigned long *) 0x56000048)
                       
#define GPFCON               (*(volatile unsigned long *) 0x56000050)
#define GPFDAT               (*(volatile unsigned long *) 0x56000054)
#define GPFUP                (*(volatile unsigned long *) 0x56000058)
                       
#define GPGCON               (*(volatile unsigned long *) 0x56000060)
#define GPGDAT               (*(volatile unsigned long *) 0x56000064)
#define GPGUP                (*(volatile unsigned long *) 0x56000068)
                       
#define GPHCON               (*(volatile unsigned long *) 0x56000070)
#define GPHDAT               (*(volatile unsigned long *) 0x56000074)
#define GPHUP                (*(volatile unsigned long *) 0x56000078)

#define GPJCON               (*(volatile unsigned long *) 0x560000D0)
#define GPJDAT               (*(volatile unsigned long *) 0x560000D4)
#define GPJUP                (*(volatile unsigned long *) 0x560000D8)
                       
#define MISCCR               (*(volatile unsigned long *) 0x56000080)
#define DCLKCON              (*(volatile unsigned long *) 0x56000084)
#define EXTINT0              (*(volatile unsigned long *) 0x56000088)
#define EXTINT1              (*(volatile unsigned long *) 0x5600008C)
#define EXTINT2              (*(volatile unsigned long *) 0x56000090)
#define EINTFLT0             (*(volatile unsigned long *) 0x56000094)
#define EINTFLT1             (*(volatile unsigned long *) 0x56000098)
#define EINTFLT2             (*(volatile unsigned long *) 0x5600009C)
#define EINTFLT3             (*(volatile unsigned long *) 0x560000A0)
#define EINTMASK             (*(volatile unsigned long *) 0x560000A4)
#define EINTPEND             (*(volatile unsigned long *) 0x560000A8)
#define GSTATUS0             (*(volatile unsigned long *) 0x560000AC)
#define GSTATUS1             (*(volatile unsigned long *) 0x560000B0)
#define GSTATUS2             (*(volatile unsigned long *) 0x560000B4)
#define GSTATUS3             (*(volatile unsigned long *) 0x560000B8)
#define GSTATUS4             (*(volatile unsigned long *) 0x560000BC)
#define MSLCON               (*(volatile unsigned long *) 0x560000CC)

// RTC
#ifdef  __BIG_ENDIAN
#define RTCCON               (*(volatile unsigned char *) 0x57000043)
#define TICNT                (*(volatile unsigned char *) 0x57000047)
#define RTCALM               (*(volatile unsigned char *) 0x57000053)
#define ALMSEC               (*(volatile unsigned char *) 0x57000057)
#define ALMMIN               (*(volatile unsigned char *) 0x5700005B)
#define ALMHOUR              (*(volatile unsigned char *) 0x5700005F)
#define ALMDATE              (*(volatile unsigned char *) 0x57000063)
#define ALMMON               (*(volatile unsigned char *) 0x57000067)
#define ALMYEAR              (*(volatile unsigned char *) 0x5700006B)
#define RTCRST               (*(volatile unsigned char *) 0x5700006F)
#define BCDSEC               (*(volatile unsigned char *) 0x57000073)
#define BCDMIN               (*(volatile unsigned char *) 0x57000077)
#define BCDHOUR              (*(volatile unsigned char *) 0x5700007B)
#define BCDDATE              (*(volatile unsigned char *) 0x5700007F)
#define BCDDAY               (*(volatile unsigned char *) 0x57000083)
#define BCDMON               (*(volatile unsigned char *) 0x57000087)
#define BCDYEAR              (*(volatile unsigned char *) 0x5700008B)

#else   //Little Endian
#define RTCCON               (*(volatile unsigned char *) 0x57000040)
#define TICNT                (*(volatile unsigned char *) 0x57000044)
#define RTCALM               (*(volatile unsigned char *) 0x57000050)
#define ALMSEC               (*(volatile unsigned char *) 0x57000054)
#define ALMMIN               (*(volatile unsigned char *) 0x57000058)
#define ALMHOUR              (*(volatile unsigned char *) 0x5700005C)
#define ALMDATE              (*(volatile unsigned char *) 0x57000060)
#define ALMMON               (*(volatile unsigned char *) 0x57000064)
#define ALMYEAR              (*(volatile unsigned char *) 0x57000068)
#define RTCRST               (*(volatile unsigned char *) 0x5700006C)
#define BCDSEC               (*(volatile unsigned char *) 0x57000070)
#define BCDMIN               (*(volatile unsigned char *) 0x57000074)
#define BCDHOUR              (*(volatile unsigned char *) 0x57000078)
#define BCDDATE              (*(volatile unsigned char *) 0x5700007C)
#define BCDDAY               (*(volatile unsigned char *) 0x57000080)
#define BCDMON               (*(volatile unsigned char *) 0x57000084)
#define BCDYEAR              (*(volatile unsigned char *) 0x57000088)
#endif

// A/D Converter
#define ADCCON               (*(volatile unsigned long *) 0x58000000)
#define ADCTSC               (*(volatile unsigned long *) 0x58000004)
#define ADCDLY               (*(volatile unsigned long *) 0x58000008)
#define ADCDAT0              (*(volatile unsigned long *) 0x5800000C)
#define ADCDAT1              (*(volatile unsigned long *) 0x58000010)
#define ADCUPDN              (*(volatile unsigned long *) 0x58000014)          
                       
// SPI         
#define SPCON0               (*(volatile unsigned long *) 0x59000000)
#define SPSTA0               (*(volatile unsigned long *) 0x59000004)
#define SPPIN0               (*(volatile unsigned long *) 0x59000008)
#define SPPRE0               (*(volatile unsigned long *) 0x5900000C)
#define SPTDAT0              (*(volatile unsigned long *) 0x59000010)
#define SPRDAT0              (*(volatile unsigned long *) 0x59000014)

#define SPCON1               (*(volatile unsigned long *) 0x59000020)
#define SPSTA1               (*(volatile unsigned long *) 0x59000024)
#define SPPIN1               (*(volatile unsigned long *) 0x59000028)
#define SPPRE1               (*(volatile unsigned long *) 0x5900002C)
#define SPTDAT1              (*(volatile unsigned long *) 0x59000030)
#define SPRDAT1              (*(volatile unsigned long *) 0x59000034)

// SD Interface
#define SDICON               (*(volatile unsigned long *) 0x5A000000)
#define SDIPRE               (*(volatile unsigned long *) 0x5A000004)
#define SDICARG              (*(volatile unsigned long *) 0x5A000008)
#define SDICCON              (*(volatile unsigned long *) 0x5A00000C)
#define SDICSTA              (*(volatile unsigned long *) 0x5A000010)
#define SDIRSP0              (*(volatile unsigned long *) 0x5A000014)
#define SDIRSP1              (*(volatile unsigned long *) 0x5A000018)
#define SDIRSP2              (*(volatile unsigned long *) 0x5A00001C)
#define SDIRSP3              (*(volatile unsigned long *) 0x5A000020)
#define SDIDTIMER            (*(volatile unsigned long *) 0x5A000024)
#define SDIBSIZE             (*(volatile unsigned long *) 0x5A000028)
#define SDIDCON              (*(volatile unsigned long *) 0x5A00002C)
#define SDIDCNT              (*(volatile unsigned long *) 0x5A000030)
#define SDIDSTA              (*(volatile unsigned long *) 0x5A000034)
#define SDIFSTA              (*(volatile unsigned long *) 0x5A000038)
#define SDIIMSK              (*(volatile unsigned long *) 0x5A00003C)
#define SDIDAT               (*(volatile unsigned char *) 0x5A000040)

#ifdef __BIG_ENDIAN
#undef  SDIDAT
#define SDIDAT               (*(volatile unsigned char *) 0x5A000043)
#endif

// AC97 Audio-CODEC Interface
#define AC_GLBCTRL           (*(volatile unsigned long *) 0x5B000000)
#define AC_GLBSTAT           (*(volatile unsigned long *) 0x5B000004)
#define AC_CODEC_CMD         (*(volatile unsigned long *) 0x5B000008)
#define AC_CODEC_STAT        (*(volatile unsigned long *) 0x5B00000C)
#define AC_PCMADDR           (*(volatile unsigned long *) 0x5B000010)
#define AC_MICADDR           (*(volatile unsigned long *) 0x5B000014)
#define AC_PCMDATA           (*(volatile unsigned long *) 0x5B000018)
#define AC_MICDATA           (*(volatile unsigned long *) 0x5B00001C)

// Interrupt Pending Bit
#define BIT_EINT0            (1 <<  0)
#define BIT_EINT1            (1 <<  1)
#define BIT_EINT2            (1 <<  2)
#define BIT_EINT3            (1 <<  3)
#define BIT_EINT4_7          (1 <<  4)
#define BIT_EINT8_23         (1 <<  5)
#define BIT_CAM              (1 <<  6)
#define BIT_nBAT_FLT         (1 <<  7)
#define BIT_TICK             (1 <<  8)
#define BIT_WDT_AC97         (1 <<  9)
#define BIT_TIMER0           (1 << 10)
#define BIT_TIMER1           (1 << 11)
#define BIT_TIMER2           (1 << 12)
#define BIT_TIMER3           (1 << 13)
#define BIT_TIMER4           (1 << 14)
#define BIT_UART2            (1 << 15)
#define BIT_LCD              (1 << 16)
#define BIT_DMA0             (1 << 17)
#define BIT_DMA1             (1 << 18)
#define BIT_DMA2             (1 << 19)
#define BIT_DMA3             (1 << 20)
#define BIT_SDI              (1 << 21)
#define BIT_SPI0             (1 << 22)
#define BIT_UART1            (1 << 23)
#define BIT_NFCON            (1 << 24)
#define BIT_USBD             (1 << 25)
#define BIT_USBH             (1 << 26)
#define BIT_IIC              (1 << 27)
#define BIT_UART0            (1 << 28)
#define BIT_SPI1             (1 << 29)
#define BIT_RTC              (1 << 30)
#define BIT_ADC              (1 << 31)
#define BIT_ALLMSK           (0xFFFFFFFF)

#define BIT_SUB_RXD0         (1 <<  0)
#define BIT_SUB_TXD0         (1 <<  1)
#define BIT_SUB_ERR0         (1 <<  2)
#define BIT_SUB_RXD1         (1 <<  3)
#define BIT_SUB_TXD1         (1 <<  4)
#define BIT_SUB_ERR1         (1 <<  5)
#define BIT_SUB_RXD2         (1 <<  6)
#define BIT_SUB_TXD2         (1 <<  7)
#define BIT_SUB_ERR2         (1 <<  8)
#define BIT_SUB_TC           (1 <<  9)
#define BIT_SUB_ADC_S        (1 << 10)
#define BIT_SUB_CAM_C        (1 << 11)
#define BIT_SUB_CAM_P        (1 << 12)
#define BIT_SUB_WDT          (1 << 13)
#define BIT_SUB_AC97         (1 << 14)
#define BIT_SUB_ALLMSK       (0x000007FF)

#define ClearPending(bit)    { SRCPND = bit;    \
                               INTPND = INTPND; }

#endif // __S3C2440_H

三、编译,烧录,打开串口助手,接收到数据。

Keil5 平台 S3C2440裸机程序开发-----UART_第2张图片

你可能感兴趣的:(arm,嵌入式硬件)