Dec 24

ARM7串口通讯程序设计 不指定

piikee , 23:18 , 计算机相关 » 我的开发 , 评论(1) , 阅读(1890) , 本站原创 | |

摘要:设计ARM板到主机的网络通信

关键字:ARM 主机 计算机 通讯程序 UART 串口 接口 源码

1 引言

  背景:期末课程设计,要求设计实现ARM板到主机的网络通信
  意义和目的:借此课程设计,使得我们能够更好掌握网络通讯技术与网络编程技巧。
  


2 总体设计  

  2.1提供配置与器件
  
   ARM7板一块,串口线一条,JATA线一条,电源线一条。PC端开发平台为C#.Net平台。
  
  2.2 系统框架设计
  大致是通过在ARM板的RS232接口接收计算机传过来的数据,然后再通过RS232回传对计算机,并在计算机上显示出来。另外,如果数据需要保存,可以保存到一个txt文本文档中。



主文件MAIN.C代码:

#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"

void Main(void)
{
    unsigned char aa;
    char *string;
    rSYSCFG=CACHECFG;   // Using 8KB Cache//
    Port_Init();
    ChangePllValue( 70, 3, 1 ) ;  //设置CPU频率为78M
    Uart_Init(0,57600);
    Led_Display(0x0);
    Delay(10);
    Uart_Select(0);   //Select UART0
    Uart_Printf("\nARM通讯程序设计");
    Uart_Printf("\nPlease Press A String");
    while(1){
    Uart_GetString(string);    //从串口读取字符串
    Uart_SendString(string);  //发送字符串
    }
}



PC端C#.net开发主界面代码:
  
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;

namespace Frontwork_WindowsForms
{
    public partial class Form1 : Form
    {
        static System.IO.Ports.SerialPort _serialPort;
        public Form1()
        {
            InitializeComponent();
            _serialPort = new System.IO.Ports.SerialPort("COM1");
            _serialPort.Parity = Parity.None;        //设置校验位
            _serialPort.StopBits = StopBits.One;     //设置停止位
            _serialPort.BaudRate = 57600;           //设置波特率
            _serialPort.DataBits = 8;                //设置数据位
            _serialPort.Open();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Write();
        }
        public void Write()
        {
            try
            {
                string message = textBox2.Text;
                textBox2.Text = "";
                _serialPort.Write(message);             //向串口发送字符串message
                Thread.Sleep(10);
                string message1 = _serialPort.ReadExisting();      //读取串口字符串
                if (message1 != "")
                    textBox1.Text += message1 + "\r\n";
            }
            catch (TimeoutException)
            {
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Testread.hello(textBox1.Text);             //保存数据到arm.txt
            MessageBox.Show("保存成功");
        }

    }
}
  数据保存功能代码
//文本文件操作:创建/读取/拷贝/删除
using System;
using System.IO;
class Testread
{
    public static void hello(string aa)
    {
        //创建并写入(将覆盖已有文件)
        using (StreamWriter sw = File.CreateText("arm.txt"))
        {
            sw.WriteLine(aa);
        }

    }
}

PC端项目源文件下载
下载文件 (已下载 365 次)


ARM7源文件下载

下载文件 (已下载 452 次)


实验报告文件下载

此项目开发人员piikee  LALA XIXI对此项目保留所有权,请勿用于商业用途!
这些
2010/02/21 17:35
您好!你那的不是源码,我正在做此项目,希望你能贴出源码,非常感谢!
piikee 回复于 2010/02/21 21:56
源码文件下载里面有源码的。
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]