文档详情

AVR单片机与(Enthernet以太网)网络的连接.doc

发布:2017-08-10约2.59千字共4页下载文档
文本预览下载声明
AVR单片机与(Enthernet以太网)网络的连接 本文介绍关于ARV单片机通过一块芯片W5100上网模块与网络进行连接,一直以来对于嵌入式arduino怎么样和网络进行连接一直是我很好奇的问题,难得这几天公司给我一个关于利用嵌入式让AVR连接的应用,虽然对于英语水平还是很低下的我,没办法,为了兴趣和工作,只好硬着头皮看着外国一些关于AVR与网络连接的论坛。其中收获还是蛮大的,让自己知道了一些关于网络的知识和电路,特别是自己把一块ENC28J60上网模块的PCB顺利画出来进行生产,在画这个板的时候也是费了一番功夫,根据原理图,我觉得第12和第13引脚不应该是短路的,可是当PCB板拿到手的时候进行硬件测试,居然发现这两个引脚连在了一起。百思不得其解,把PCB板和画的图进行对比是没有错的,后来怀疑是IC的问题,但是经过看数据手册和IC不接在电路中的测试,没有问题。最近对HR911105A网口进行测试,兴奋地发现了问题是第3和第6是连在一起的。找出问题根源。 一直对于arduino这种开发平台和独特的编程风格的感兴趣。特别是他具有一个实时和电脑进行通讯的系统平台,长话短说,还是把硬件进行连接,以及代码的编写和调试,因为ardunio官方指代了一个关于Ethernet的库,所以把它下载下来,加以研究。终于写出了下面的一段代码: #include SPI.h //Test Code: /* * Web Server * * A simple web server that shows the value of the analog input pins. */ #include Ethernet.h byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192, 168, 0, 48 }; Server server(80); void setup() { Ethernet.begin(mac, ip); server.begin(); } void loop() { Client client = server.available(); if (client) { // an http request ends with a blank line boolean current_line_is_blank = true; while (client.connected()) { if (client.available()) { char c = client.read(); // if weve gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so we can send a reply if (c == n current_line_is_blank) { // send a standard http response header client.println(HTTP/1.1 200 OK); client.println(Content-Type: text/html); client.println(); // output the value of each analog input pin client.print(welcome to B2CQSHOP); client.println(br /); client.print(//*************************************); client.println(br /); client.print(); client.println(br /); client.print(//*************************************); client.println(br /); for (int i = 0; i 6; i++) { client.print(analog input ); client.print(i); client.print( is ); client.print(analogRead(i)); client.println(br /); } break; } if (c == n) { // were starting a new line current_line_is_blank = true; } else if (c != r) { // weve gotten a character on the curren
显示全部
相似文档