?? main.c
字號:
/* 包含文件 */
#include "def.h"
#include "2410lib.h"
#include "option.h"
#include "2410addr.h"
#include "interrupt.h"
/********************************************************************
// Function name : Main
// Description : JXARM9-2410 RS485通信實驗主程序
// 實現功能:
// 實現JXARM9-2410 RS485回環測試
// JXARM9-2410 UART0 <==> PC COM
// Return type : void
// Argument : void
*********************************************************************/
void Main(void)
{
unsigned char data[6] = {0, 1, 2, 3, 4, 5};
unsigned char ch = 'a';
/* 配置系統時鐘 */
ChangeClockDivider(1,1); // 1:2:4
ChangeMPllValue(0xa1,0x3,0x1); // FCLK=202.8MHz
/* 初始化端口 */
Port_Init();
/* 初始化串口 */
Uart_Init(0,115200);
Uart_Select(0);
/* 打印提示信息 */
PRINTF("\n---RS485通訊程序(回環測試,請將主板上的JP12和JP13跳線接上)---\n");
PRINTF("\n---在超級終端中輸入數據,然后將該數據發送到RS485,RS485將數據回送到UART2,從UART2接收到數據后在UART0中進行顯示---\n");
/* 開始測試 */
// Additional configuration for UART2 port
rGPHCON&=0x3fafff; // TXD2,RXD2
while(1)
{
/* 從UART0獲取數據 */
Uart_Select(0);
ch = Uart_Getch();
/* 將接收到的數據發送到RS485 */
Uart_Select(2);
Uart_SendByte(ch);
/* 從RS485獲取數據 */
Uart_Select(2);
ch = Uart_Getch();
/* 將接收到的數據顯示到UART0 */
Uart_Select(0);
Uart_Printf("%c", ch);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -