如何用Labview编程实现并口模拟IIC总线

如何用Labview编程实现并口模拟IIC总线,第1张

设定一个线为时钟,把你的数据转换为十六进制然后在时钟低进行反转。

读取时别忘了地址加一,另外程序要使用串行结构这样才能同步。

并口焊接一个330OHM电阻限流。

暂时就想到这么多

到的是一些并口的汇编程序.并且也没有对应于12232F的并口程序,串口的C51程序极少见,为了方便大家使用.本程序在AT89S52单片机上已经调试成功,有什么问题,大家多多交流指教.使用这款LCD应该要注意的问题<br>一定要在VO与VDD及VSS这三个脚间接一个20K的电位器<br>电位器的中间脚接VO,其它二脚接VDD和VSS<br>然后调节电位器的大小,直到有显示为止。欢迎大家提出意见

#include <reg52.h>

#define uint unsigned int

#define uchar unsigned char

#define x10x80

#define x20x88

#define y 0x80

#define comm 0

#define dat 1

sbit cs = P3^3

sbit std = P3^1

sbit sclk = P3^0

void wr_lcd (uchar dat_comm,uchar content)

void delay (uint us)

uchar code tab1[]={

"天行健君子以自强不息"

"地势坤君子以厚德载物"

}

uchar code tab31[]={

"北京欢迎你WelcometoBeijing"

}

uchar code tab32[]={

/*-- 调入了一幅图像:F:\梁\画图\HOCO12832.bmp --*/

/*-- 宽度x高度=128x32 --*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x18,0x0C,0x00,0x00,0x01,0x00,0x00,0x00,0x00,

0x01,0xFF,0x80,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x13,0x10,0x03,0xFE,0x00,

0x03,0xFF,0xC0,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x3F,0x30,0x1F,0xFF,0xC0,

0x03,0xFF,0xE0,0x00,0x00,0x00,0x00,0x8C,0x03,0xF0,0x00,0x7F,0xE0,0x7C,0x01,0xE0,

0x03,0xFF,0xF0,0x00,0x00,0x00,0x01,0x36,0x06,0xC0,0x00,0x5F,0xC0,0xFF,0xFC,0x60,

0x01,0xFF,0xF0,0x00,0x00,0x00,0x02,0x1B,0x0F,0x80,0x00,0xFF,0x01,0xFE,0x0F,0x30,

0x00,0xEF,0xF0,0x00,0x00,0x00,0x02,0x6D,0x9F,0x00,0x00,0x3E,0x03,0xFF,0xF1,0x90,

0x00,0xFF,0xF8,0x00,0x00,0x00,0x04,0x36,0xFE,0x00,0x01,0xFF,0x07,0xFF,0xFC,0x90,

0x00,0xEF,0xFF,0xFF,0x80,0x00,0x04,0xDB,0x7E,0x00,0x03,0xFF,0x87,0xFF,0xFC,0xD0,

0x00,0x0F,0xFF,0xFF,0xC0,0x00,0x04,0x6D,0xFC,0x00,0x07,0xFF,0x8F,0xFF,0xFE,0x50,

0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x36,0xFC,0x10,0x07,0xFF,0x8F,0xFF,0xFE,0x90,

0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x1B,0xF8,0x10,0x07,0xFF,0xCF,0xFF,0xFE,0x80,

0x00,0x0F,0xFF,0xFF,0xF0,0x00,0x04,0x0F,0xF8,0x10,0x07,0xFF,0xFF,0xFF,0xFA,0x00,

0x00,0x07,0xFF,0xFF,0xF0,0x00,0x04,0x07,0xF0,0x10,0x07,0xFF,0xFF,0xFF,0xFA,0x00,

0x00,0xFF,0xFF,0xFF,0xF8,0x00,0x02,0x03,0xF0,0x20,0x07,0xFF,0xFF,0xFF,0xBA,0x00,

0x00,0xFD,0xFF,0xFF,0xFC,0x00,0x02,0x03,0xF0,0x20,0x03,0xFF,0xFF,0xDF,0xB8,0x00,

0x00,0xC1,0xC0,0x3F,0xFC,0x00,0x01,0x01,0xE0,0x40,0x00,0xFF,0xFF,0xDF,0xB0,0x00,

0x00,0x81,0xC0,0x3F,0xCE,0x00,0x00,0x81,0xE0,0x80,0x00,0x7F,0xFF,0xDF,0xA0,0x00,

0x00,0x81,0x80,0x1D,0xCF,0x00,0x00,0x41,0xE1,0x00,0x00,0x3F,0xFF,0x9B,0x00,0x00,

0x01,0x83,0x80,0x1F,0xC7,0x80,0x00,0x21,0xE2,0x00,0x00,0x1F,0xFD,0xB6,0x00,0x00,

0x01,0xC3,0x00,0x0E,0xE6,0x80,0x00,0x19,0xEC,0x00,0x00,0x07,0xFE,0x20,0x00,0x00,

0x00,0xC3,0x00,0x07,0x67,0x40,0x00,0x07,0xF0,0x00,0x00,0x03,0x3E,0x00,0x00,0x00,

0x00,0x02,0x00,0x03,0xE7,0xA0,0x00,0x00,0x00,0x00,0x00,0x02,0x8E,0x00,0x00,0x00,

0x00,0x06,0x00,0x03,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x00,0x00,0x00,

0x00,0x06,0x00,0x07,0x03,0x00,0x77,0x46,0x74,0x24,0x80,0x06,0x04,0x00,0x00,0x00,

0x00,0x1C,0x00,0x06,0x00,0x00,0x55,0x45,0x54,0x57,0x80,0x00,0x00,0x00,0x00,0x00,

0x00,0x1C,0x00,0x0E,0x00,0x00,0x45,0x45,0x74,0x57,0x80,0x08,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x1C,0x00,0x00,0x55,0x45,0x44,0x74,0x80,0xF0,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x38,0x00,0x00,0x77,0x76,0x47,0x54,0x80,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

}

uchar code tab5[]={

/*-- 调入了一幅图像:F:\梁\画图\COCK.bmp --*/

/*-- 宽度x高度=128x64 --*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x80,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x0C,0x43,0x01,0x80,0x00,0x7F,0xFF,0xF0,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x19,0xFF,0x07,0x00,0x07,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x01,0x3F,0xFC,0x1E,0x00,0x1F,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,

0x00,0x00,0x00,0x01,0xBF,0xFF,0xFC,0x00,0x7F,0xFC,0x00,0x7F,0xC0,0x00,0x00,0x00,

0x00,0x00,0x00,0x01,0xFF,0xFF,0xF0,0x00,0xFF,0xC0,0x00,0x0F,0xE0,0x00,0x00,0x00,

0x00,0x00,0x00,0x01,0xFF,0xFF,0xE0,0x03,0xFF,0xFF,0xFC,0x01,0xF0,0x00,0x00,0x00,

0x00,0x00,0x00,0x01,0xDF,0xFF,0xC0,0x07,0xFF,0xFF,0xFF,0x80,0xF0,0x00,0x00,0x00,

0x00,0x00,0x00,0x03,0xFF,0xFF,0x00,0x0F,0xFF,0xFF,0xFF,0xE0,0x38,0x00,0x00,0x00,

0x00,0x00,0x00,0x07,0xFF,0xF8,0x00,0x1F,0xFF,0xF0,0x03,0xF8,0x38,0x00,0x00,0x00,

0x00,0x00,0x00,0x07,0xFF,0xE0,0x00,0x3F,0xFF,0xFF,0xC0,0x7C,0x18,0x00,0x00,0x00,

0x00,0x00,0x00,0x04,0x7F,0xF0,0x00,0x3F,0xFF,0xFF,0xF8,0x1E,0x08,0x00,0x00,0x00,

0x00,0x00,0x00,0x01,0xFF,0xF8,0x00,0x7F,0xFF,0xFF,0xFE,0x0F,0x08,0x00,0x00,0x00,

0x00,0x00,0x00,0x0F,0xFF,0xFC,0x00,0xFF,0xFF,0xFF,0xFF,0x87,0x08,0x00,0x00,0x00,

0x00,0x00,0x00,0x1F,0xFF,0xFE,0x00,0xFF,0xFF,0xFF,0xFF,0x83,0x88,0x00,0x00,0x00,

0x00,0x00,0x00,0x3F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xC3,0x88,0x00,0x00,0x00,

0x00,0x00,0x00,0x7F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00,

0x00,0x00,0x00,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00,

0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF1,0x88,0x00,0x00,0x00,

0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF3,0x08,0x00,0x00,0x00,

0x00,0x00,0x01,0xFF,0xFF,0xFF,0x07,0xFF,0xFF,0xFF,0xFF,0xF2,0x10,0x00,0x00,0x00,

0x00,0x00,0x01,0xFF,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xF0,0x20,0x00,0x00,0x00,

0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,

0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x70,0x00,0x00,0x00,0x00,

0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00,

0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x7E,0x20,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x3E,0x40,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFF,0x3C,0x40,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFE,0x38,0x40,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x38,0x40,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x30,0x40,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x1F,0x7C,0x20,0x40,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x1E,0x78,0x00,0x40,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFE,0x1E,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xDA,0x3C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF2,0x30,0x80,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF1,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x7C,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x78,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x72,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x01,0x40,0x04,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x02,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x02,0x40,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x0C,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x38,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x0F,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

}

/*----初始化-----*/

void init_lcd (void)

{

wr_lcd (comm,0x30) /*30---基本指令动作*/

wr_lcd (comm,0x01) /*清屏,地址指针指向00H*/

delay (100)

wr_lcd (comm,0x06) /*光标的移动方向*/

wr_lcd (comm,0x0c) /*开显示,关游标*/

}

/*----上半屏显示汉字或字符----*/

void chn_dispup (uchar code *chn)

{

uchar i,j

wr_lcd (comm,0x30) //30---基本指令动作

wr_lcd (comm,0x80) //把显示地址设为0X80,即为第一行的首位--第一页

j=0

for (i=0i<16i++)

wr_lcd (dat,chn[j*16+i])

}

/*----下半屏显示汉字或字符---*/

void chn_dispdown (uchar code *chn)

{

uchar i,j

wr_lcd (comm,0x30) /*30---基本指令动作*/

wr_lcd (comm,0x90) //把显示地址设为0X90,即为第二行的首位--第二页

j=0

for (i=0i<16i++)

wr_lcd (dat,chn[j*16+i])

}

/*---上下半屏顺序显示汉字或字符----*/

void chn_disp1 (uchar code *chn)

{

uchar i,j

wr_lcd (comm,0x30) /*30---基本指令动作*/

wr_lcd (comm,0x80) //把显示地址设为0X80,即为第一行的首位--第一页

j=0

for (i=0i<16i++)

wr_lcd (dat,chn[j*16+i])

wr_lcd (comm,0x90) //把显示地址设为0X90,即为第二行的首位--第二页

j=1

for (i=0i<16i++)

wr_lcd (dat,chn[j*16+i])

}

/*----显示图形----*/

void img_disp (uchar code *img)

{

uchar i,j

for(j=0j<32j++)

{

for(i=0i<8i++)

{

wr_lcd (comm,0x34) //扩充指令 *** 作

wr_lcd (comm,y+j)//先将垂直的字节坐标(Y)写入绘图RAM 地址

wr_lcd (comm,x1+i) //再将水平的字节坐标(X)写入绘图RAM 地址。

wr_lcd (comm,0x30) //基本指令动作

wr_lcd (dat,img[j*16+i*2]) //写入第一个Bytes

wr_lcd (dat,img[j*16+i*2+1]) //写入第二个Bytes

}

}

for(j=32j<64j++)

{

for(i=0i<8i++)

{

wr_lcd (comm,0x34) //扩充指令 *** 作

wr_lcd (comm,y+j-32) //先将垂直的字节坐标(Y)写入绘图RAM 地址

wr_lcd (comm,x2+i) //再将水平的字节坐标(X)写入绘图RAM 地址

wr_lcd (comm,0x30) //基本指令动作

wr_lcd (dat,img[j*16+i*2]) //写入第一个Bytes

wr_lcd (dat,img[j*16+i*2+1]) //写入第二个Bytes

}

}

wr_lcd (comm,0x36)

}

/*--------显示点阵-----------*/

void lat_disp (uchar data1,uchar data2)//data1,data2是要显示的数据

{

uchar i,j,k,x

x=x1

for(k=0k<2k++)

{

for(j=0j<16j++)

{

for(i=0i<8i++)

{

wr_lcd (comm,0x34) //扩充指令 *** 作

wr_lcd (comm,y+j*2)//先将垂直的字节坐标(Y)写入绘图RAM 地址

wr_lcd (comm,x+i) //再将水平的字节坐标(X)写入绘图RAM 地址

wr_lcd (comm,0x30) //功能设置:一次送8位数据,基本指令集

wr_lcd (dat,data1) //写入第一个Bytes

wr_lcd (dat,data1) //写入第二个Bytes

}

for(i=0i<8i++)

{

wr_lcd (comm,0x34) //扩充指令 *** 作

wr_lcd (comm,y+j*2+1)//先将垂直的字节坐标(Y)写入绘图RAM 地址

wr_lcd (comm,x+i)//再将水平的字节坐标(X)写入绘图RAM 地址

wr_lcd (comm,0x30) //基本指令 *** 作

wr_lcd (dat,data2) //写入第一个Bytes

wr_lcd (dat,data2) //写入第二个Bytes

}

}

x=x2

}

wr_lcd (comm,0x36)

}

/*--------------清DDRAM------------------*/

void clrram (void)

{

wr_lcd (comm,0x30)

wr_lcd (comm,0x01)

delay (180)

}

/*---------------------------------------*/

void wr_lcd (uchar dat_comm,uchar content)

{

uchar a,i,j

delay (50)

a=content

cs=1

sclk=0

std=1

for(i=0i<5i++)

{

sclk=1

sclk=0

}

std=0

sclk=1

sclk=0

if(dat_comm)

std=1 //data

else

std=0 //command

sclk=1

sclk=0

std=0

sclk=1

sclk=0

for(j=0j<2j++)

{

for(i=0i<4i++)

{

a=a<<1

std=CY

sclk=1

sclk=0

}

std=0

for(i=0i<4i++)

{

sclk=1

sclk=0

}

}

}

/*-----------------------------------*/

void delay (uint us) //delay time

{

while(us--)

}

void delay1 (uint ms)

{

uint i,j

for(i=0i<msi++)

for(j=0j<15j++)

delay(1)

}

/*------------------主程序--------------------*/

void main ()

{

SP=0x5f

init_lcd ()

while (1)

{

clrram()

lat_disp (0x00,0x00)//显示点阵

delay1 (8000)

clrram()

lat_disp (0xcc,0xcc)//显示点阵

delay1 (8000)

clrram()

chn_disp1 (tab1) //上下半屏顺序显示汉字或字符

delay1 (8000)

clrram()

lat_disp (0xff,0x00) //显示点阵

delay1 (8000)

img_disp (tab5) //显示图形

delay1 (8000)

clrram()

chn_dispup (tab31)//上半屏顺序显示汉字或字符

delay1 (8000)

clrram()

chn_dispdown (tab31)//下半屏顺序显示汉字或字符

delay1 (8000)

}

}

选择交换机switch0进行配置。思科模拟器并口能设置时选择交换机switch0进行配置,进入特权模式。思科模拟器软件功能是一个功能强大的网络仿真程序,允许学生实验与网络行为。我们可以使用这款软件设计和布置网络拓扑图,真实模拟网络设备使用。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12045976.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存