?????????s3c2440??UART???????
???????????? ???????[ 2015/2/25 15:48:23 ] ??????????????? ???????
/* ????????UART.c
/* ?????????????UART?????????
/* ???????jianqi
/* ?汾??1.0
#include"2440addr.h" //????2440?????????????
#include"def.h"
//???LED???GPB5.6.7.8??
#define LED1 5
#define LED2 6
#define LED3 7
#define LED4 8
#define BAUD 115200 //??????
#define Bit??x?? ??1??x?? //???λ??λ
#define Output??x?? ??1??2*x?? //?????IO??????
#define LED_On??x?? rGPBDAT=~Bit??x?? //???????LED
* ?????Clk_Set
* ???????????????????
* ??????????
* ???????????
void Clk_Set??void??
{
int count;
rUPLLCON=??56??12??|??2??4??|2; //UCLK?48MHZ
rMPLLCON=??92??12??|??1??4??|1; //FCLK?400MHZ
rCLKDIVN=??0??3??|??2??1??|1;//HCLKλ100MHZ??PCLK?50MHZ
rCAMDIVN=??0??9???? //PCLK=HCLK/4
}
* ?????IO_init
* ?????????LED????????
* ??????????
* ???????????
void IO_init??void??
{
rGPBCON=Output??LED1??|Output??LED2??|Output??LED3??|Output??LED4???? //LED??IO????????
rGPBDAT=0xffff; //LED??????
}
* ?????UART0_init
* ?????UART0????????????
* ??????????
* ???????????
void UART0_init??void??
{
rGPHCON=0xa0; //IO?????UART0????
rGPHUP=0xff; //???????
rULCON0=0x03; // 8λ???????У?飬1λ??λ
rUCON0=0x05; //pclk?????ж???????Tx-?????Rx-????
rUBRDIV0=26; //???ò?????
rUFCON0=0x00; //?????FIFO
rUMCON0=0x00; //?????????
}
* ?????Send_Byte
* ???????????????
* ???????????????????
* ???????????
void Send_Byte??char data??
{
while??????rUTRSTAT0&0x2?????? //??????????????
rUTXH0=data;
}
* ?????Send_String
* ??????????????
* ?????????????????????
* ???????????
void Send_String??char* pt??
{
while??*pt??
{
Send_Byte??*pt++????
}
}
* ?????Uart_Getch
* ???????????????
* ??????????
* ?????????????????
char Uart_Getch??void??
{
while??????rUTRSTAT0&0x1?????? //??????????????????
return ??rURXH0???? //????????
}
* ?????Main
* ?????????UART???????????
* ??????????
* ???????????
void Main??void??
{
char temp;
IO_init??????
UART0_init??????
Clk_Set??????
Send_String??"HelloWorld"???? //?????????
while??1??
{
temp=Uart_Getch?????? //????????
if??temp==0x01??
{
LED_On??LED1????
}
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11