双口RAM

更新时间:2024-07-09 07:19:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

双口RAM

1.模块功能:

双口RAM模块主要采用IDT7132等器件,它是一种特殊的数据存储芯片,它既可以用于单片机存储大容量的数据,也可以以双口RAM为共享存储器来实现两个处理器之间的通信和数据传输。双口RAM的优点是提供了两条完全独立的端口,每个端口都有完整的地址、数据和控制总线,允许两个CPU对双端口存储器的同一单元进行同时存取;具有两套完全独立的终端逻辑来实现两个CPU之间的握手控制信号;具有两套独立的“忙”逻辑,保证两个CPU同时对同一单元进行读/写操作的正确性。对于单个CPU而言,双口RAM同普通RAM没有什么明显的区别。 本模块原理图见图1。

图 1

3.主要器件: (1)IDT7132: (a)器件功能:

IDT7132是高速2k*8端口静态RAM,可提供 图2.1.3 IDT7132引脚图 两个拥有独立的控制总线、地址总线和I/O总线端口,允许CPU独立访问内部的任何存储单元。当/CE 引脚出现下降沿时,选中DPRAM即可通过控制OE 或R/W来访问内部存储单元。 (b) 器件引脚:

IDT7132的引脚图如图2所示。 /CE、/CER:(左、右)片选控制信号。 R/WL、R/WR:(左、右)读写控制信号。 /OEL、/OER:(左、右)使能控制信号。 /BUSYL、/BUSYR:(左、右)繁忙查询控制信号。 A0L—A9L、A0R—A9R:(左、右)地址总线。 I/O0L—I/O7L、I/O0R—I/O7R:(左、右)输入/ 输出总线。 VCC:电源。 (c) 工作原理:

IDT7132的工作时序如图3所示。它与RAM的读写时序非常类似。当CPU选中DPRAM时/CE引脚出现下降沿,当控制线/OE为高且R/W 为低时,CPU对内部存储单元进行写操作;而当控制线OE为低且R/W为高时,CPU对内部存储单元进行读操作。当外部CPU通过两个端口对双口RAM

内部的同一个存储单元进行操作时,系统将出现竞 图 2

争。这种竞争一般有如下两种模式:

(1) 如果两个端口的总线访问地址相同,并先于片选信号/CE有效,则片

内逻辑将在CEL与CER之间发生竞争。

(2) 如果两个端口的片选信号CE在地址信号有效之前变低,则片内控制

逻辑将在地址信号到达时发生竞争。

为避免因竞争而导致的通讯失败,设计者提出了意下三种常见的解决方案。(1) 设置标志位:在开辟数据通讯区的同时,可通过软件方法在某个固定

的存储单元设立标志位。这种方法要求

两端CPU每次访问双 图 3

口RAM之前,必须查询、测试和设置标志位,然后再根据标志位的状态决定是否可以访问数据区;有的双口RAM本身就具有专用的一个或多个硬件标志所存器和专门的测试和设置指令,可直接对标志位进行读/写操作。这种方法通常用在多个处理器共享一个存储器块时。

为了保证通讯数据的完整性,在采用这种方法时往往要求每个处理器能对该存储器块进行互斥的存取

(2) 软件查询BUSY引脚状态:双口RAM必须具有解决两个处理器同时

访问同一单元的竞争仲裁逻辑功能。当双方访问地址发生冲突时,竞争仲裁逻辑可用来决定哪个端口访问有效,同时取消无效端口的访问操作,并将禁止端口的BUSY信号之为低电平。因此BUSY信号可作为处理器等待逻辑的输入之一,即当BUSY为低电平时,让处理器进入等待状态。每次访问双口RAM时,CPU检查BUSY状态已判断是否发生竞争,只有BUSY为高时,对双口RAM的操作才有效。

(3) 利用硬件解决竞争:将BUSY信号引入CPU的READY引脚可在发

生竞争时使BUSY为低,从而使CPU内部总线时序根据READY引脚状态自动插入WAIT信号并展宽总线,以达到分时访问的木的。 另外,在使用BUSY信号时必须首先将此信号接上拉电阻,其次应在BUSY信号有效期间使处理器保持读写操作以及相应的地址和数据,但是需要说明的是,在BUSY信号变高之前,这种情况下的所有操作都是无效的,图4所示是发生竞争时的时序图。

图 4

(2)74HC573: (a)器件功能:

74HC573是一个8D触发器。 (b) 器件引脚:

74HC573的引脚图如图5所示,器件的内部电路如图6所示。

图 5 图 6

/OE:输出控制线,当OE为高电平时,输出为高阻态,当OE为低电平时,输出端为触发器中的数据。

LE:控制器的数据保持功能使能线,当LE为高电平时,触发起位保持作用,这时触发器存储了LE上升沿时触发器输入端的状态。 D0—D7:数据输入端。 Q0—Q7:数据输出端。 GND:接地。 VCC:接电源。 (c)工作原理:

74HC573的功能表如图7所示。

图 7 (3)74LS245: (a)器件功能:

74LS245是双向三态缓冲器。

ab,0Xab,

0Xaa,0Xaa,0Xaa,0Xa9,0Xa9,0Xa8,0Xa8,0Xa8,0Xa7,0Xa7,0Xa7,0Xa6,0Xa6,0Xa5,0Xa5,0Xa5,

0Xa4,0Xa4,0Xa4,0Xa3,0Xa3,0Xa2,0Xa2,0Xa2,0Xa1,0Xa1,0Xa1,0Xa0,0Xa0,0X9f,0X9f,0X9f,

0X9e,0X9e,0X9e,0X9d,0X9d,0X9c,0X9c,0X9c,0X9b,0X9b,0X9b,0X9a,0X9a,0X99,0X99,0X99,

0X98,0X98,0X97,0X97,0X97,0X96,0X96,0X96,0X95,0X95,0X94,0X94,0X94,0X93,0X93,0X92,

0X92,0X92,0X91,0X91,0X90,0X90,0X90,0X8f,0X8f,0X8f,0X8e,0X8e,0X8d,0X8d,0X8d,0X8c,

0X8c,0X8b,0X8b,0X8b,0X8a,0X8a,0X89,0X89,0X89,0X88,0X88,0X88,0X87,0X87,0X86,0X86,

0X86,0X85,0X85,0X84,0X84,0X84,0X83,0X83,0X82,0X82,0X82,0X81,0X81,0X80,0X80,0X80,

0X7f,0X7f,0X7f,0X7e,0X7e,0X7d,0X7d,0X7d,0X7c,0X7c,0X7b,0X7b,0X7b,0X7a,0X7a,0X79,

0X79,0X79,0X78,0X78,0X77,0X77,0X77,0X76,0X76,0X76,0X75,0X75,0X74,0X74,0X74,0X73,

0X73,0X72,0X72,0X72,0X71,0X71,0X70,0X70,0X70,0X6f,0X6f,0X6f,0X6e,0X6e,0X6d,0X6d,

0X6d,0X6c,0X6c,0X6b,0X6b,0X6b,0X6a,0X6a,0X6a,0X69,0X69,0X68,0X68,0X68,0X67,0X67,

0X66,0X66,0X66,0X65,0X65,0X65,0X64,0X64,0X63,0X63,0X63,0X62,0X62,0X61,0X61,0X61,

0X60,0X60,0X60,0X5f,0X5f,0X5e,0X5e,0X5e,0X5d,0X5d,0X5d,0X5c,0X5c,0X5b,0X5b,0X5b,

0X5a,0X5a,0X5a,0X59,0X59,0X58,0X58,0X58,0X57,0X57,0X57,0X56,0X56,0X55,0X55,0X55,

0X54,0X54,0X54,0X53,0X53,0X53,0X52,0X52,0X51,0X51,0X51,0X50,0X50,0X50,0X4f,0X4f,

0X4f,0X4e,0X4e,0X4d,0X4d,0X4d,0X4c,0X4c,0X4c,0X4b,0X4b,0X4b,0X4a,0X4a,0X4a,0X49,

0X49,0X48,0X48,0X48,0X47,0X47,0X47,0X46,0X46,0X46,0X45,0X45,0X45,0X44,0X44,0X44,

0X43,0X43,0X43,0X42,0X42,0X41,0X41,0X41,0X40,0X40,0X40,0X3f,0X3f,0X3f,0X3e,0X3e,

0X3e,0X3d,0X3d,0X3d,0X3c,0X3c,0X3c,0X3b,0X3b,0X3b,0X3a,0X3a,0X3a,0X39,0X39,0X39,

0X38,0X38,0X38,0X38,0X37,0X37,0X37,0X36,0X36,0X36,0X35,0X35,0X35,0X34,0X34,0X34,

0X33,0X33,0X33,0X32,0X32,0X32,0X32,0X31,0X31,0X31,0X30,0X30,0X30,0X2f,0X2f,0X2f,

0X2e,0X2e,0X2e,0X2e,0X2d,0X2d,0X2d,0X2c,0X2c,0X2c,0X2b,0X2b,0X2b,0X2b,

0X2a,0X2a,

0X2a,0X29,0X29,0X29,0X29,0X28,0X28,0X28,0X27,0X27,0X27,0X27,0X26,0X26,0X26,0X25,

0X25,0X25,0X25,0X24,0X24,0X24,0X24,0X23,0X23,0X23,0X22,0X22,0X22,0X22,0X21,0X21,

0X21,0X21,0X20,0X20,0X20,0X20,0X1f,0X1f,0X1f,0X1f,0X1e,0X1e,0X1e,0X1e,0X1d,0X1d,

0X1d,0X1d,0X1c,0X1c,0X1c,0X1c,0X1b,0X1b,0X1b,0X1b,0X1a,0X1a,0X1a,0X1a,0X19,0X19,

0X19,0X19,0X18,0X18,0X18,0X18,0X18,0X17,0X17,0X17,0X17,0X16,0X16,0X16,0X16,0X16,

0X15,0X15,0X15,0X15,0X14,0X14,0X14,0X14,0X14,0X13,0X13,0X13,0X13,0X13,0X12,0X12,

0X12,0X12,0X12,0X11,0X11,0X11,0X11,0X11,0X10,0X10,0X10,0X10,0X10,0X0f,0X0f,0X0f,

0X0f,0X0f,0X0f,0X0e,0X0e,0X0e,0X0e,0X0e,0X0e,0X0d,0X0d,0X0d,0X0d,0X0d,0X0c,0X0c,

0X0c,0X0c,0X0c,0X0c,0X0b,0X0b,0X0b,0X0b,0X0b,0X0b,0X0b,0X0a,0X0a,0X0a,0X0a,0X0a,

0X0a,0X09,0X09,0X09,0X09,0X09,0X09,0X09,0X08,0X08,0X08,0X08,0X08,0X08,0X08,0X07,

0X07,0X07,0X07,0X07,0X07,0X07,0X07,0X06,0X06,0X06,0X06,0X06,0X06,0X06,0X06,0X06,

0X05,0X05,0X05,0X05,0X05,0X05,0X05,0X05,0X05,0X04,0X04,0X04,0X04,0X04,0X04,0X04,

0X04,0X04,0X04,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X02,

0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X01,0X01,

0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,

0X01,0X01,0X01,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,0X01,0X01,

0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X01,

0X01,0X01,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,0X02,

0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X04,0X04

,0X04,0X04,

0X04,0X04,0X04,0X04,0X04,0X04,0X04,0X05,0X05,0X05,0X05,0X05,0X05,0X05,0X05,0X05,

0X06,0X06,0X06,0X06,0X06,0X06,0X06,0X06,0X07,0X07,0X07,0X07,0X07,0X07,0X07,0X07,

0X08,0X08,0X08,0X08,0X08,0X08,0X08,0X09,0X09,0X09,0X09,0X09,0X09,0X09,0X0a,0X0a,

0X0a,0X0a,0X0a,0X0a,0X0a,0X0b,0X0b,0X0b,0X0b,0X0b,0X0b,0X0c,0X0c,0X0c,0X0c,0X0c,

0X0c,0X0d,0X0d,0X0d,0X0d,0X0d,0X0d,0X0e,0X0e,0X0e,0X0e,0X0e,0X0e,0X0f,0X0f,0X0f,

0X0f,0X0f,0X10,0X10,0X10,0X10,0X10,0X11,0X11,0X11,0X11,0X11,0X11,0X12,0X12,0X12,

0X12,0X13,0X13,0X13,0X13,0X13,0X14,0X14,0X14,0X14,0X14,0X15,0X15,0X15,0X15,0X15,

0X16,0X16,0X16,0X16,0X17,0X17,0X17,0X17,0X17,0X18,0X18,0X18,0X18,0X19,0X19,0X19,

0X19,0X1a,0X1a,0X1a,0X1a,0X1a,0X1b,0X1b,0X1b,0X1b,0X1c,0X1c,0X1c,0X1c,0X1d,0X1d,

0X1d,0X1d,0X1e,0X1e,0X1e,0X1e,0X1f,0X1f,0X1f,0X1f,0X20,0X20,0X20,0X20,0X21,0X21,

0X21,0X22,0X22,0X22,0X22,0X23,0X23,0X23,0X23,0X24,0X24,0X24,0X24,0X25,0X25,0X25,

0X26,0X26,0X26,0X26,0X27,0X27,0X27,0X28,0X28,0X28,0X28,0X29,0X29,0X29,0X2a,0X2a,

0X2a,0X2a,0X2b,0X2b,0X2b,0X2c,0X2c,0X2c,0X2c,0X2d,0X2d,0X2d,0X2e,0X2e,0X2e,0X2f,

0X2f,0X2f,0X2f,0X30,0X30,0X30,0X31,0X31,0X31,0X32,0X32,0X32,0X33,0X33,0X33,0X33,

0X34,0X34,0X34,0X35,0X35,0X35,0X36,0X36,0X36,0X37,0X37,0X37,0X38,0X38,0X38,0X39,

0X39,0X39,0X3a,0X3a,0X3a,0X3b,0X3b,0X3b,0X3c,0X3c,0X3c,0X3d,0X3d,0X3d,0X3e,0X3e,

0X3e,0X3f,0X3f,0X3f,0X40,0X40,0X40,0X41,0X41,0X41,0X42,0X42,0X42,0X43,0X43,0X43,

0X44,0X44,0X44,0X45,0X45,0X45,0X46,0X46,0X46,0X47,0X47,0X48,0X48,0X48,0X49,0X49,

0X49,0X4a,0X4a,0X4a,0X4b,0X4b,0X4b,0X4c,0X4c,0X4d,0X4d,0X4d,0X4e,0X4e,0X4e,0X4f,

0X4f,0X4f,0X50,0X50,0X50,0X51,0X51,0X52,0X52,0X52,0X53,0X53,0X53,0X54,0X54,0X55,

0X55,0X55,0X56,0X56,0X56,0X57,0X57,0X57,0X58,0X58,0X59,0X59,0X59,0X5a,0X5a,0X5a,

0X5b,0X5b,0X5c,0X5c,0X5c,0X5d,0X5d,0X5d,0X5e,0X5e,0X5f,0X5f,0X5f,0X60,0

X60,0X60,

0X61,0X61,0X62,0X62,0X62,0X63,0X63,0X64,0X64,0X64,0X65,0X65,0X65,0X66,0X66,0X67,

0X67,0X67,0X68,0X68,0X69,0X69,0X69,0X6a,0X6a,0X6a,0X6b,0X6b,0X6c,0X6c,0X6c,0X6d,

0X6d,0X6e,0X6e,0X6e,0X6f,0X6f,0X6f,0X70,0X70,0X71,0X71,0X71,0X72,0X72,0X73,0X73,

0X73,0X74,0X74,0X75,0X75,0X75,0X76,0X76,0X76,0X77,0X77,0X78,0X78,0X78,0X79,0X79,

0X7a,0X7a,0X7a,0X7b,0X7b,0X7c,0X7c,0X7c,0X7d,0X7d,0X7e,0X7e,0X7e,0X7f,0X7f,0X7f, };

uchar code Rom1[]={

0X80,0X80,0X80,0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9e,0X9e,0X9e,0X9e,0X9d,0X9d,0X9d,0X9d,0X9c,0X9c,0X9c,0X9c,

0X9b,0X9b,0X9b,0X9b,0X9a,0X9a,0X9a,0X9a,0X99,0X99,0X99,0X99,0X98,0X98,0X98,0X98,

0X97,0X97,0X97,0X97,0X96,0X96,0X96,0X96,0X95,0X95,0X95,0X95,0X94,0X94,0X94,0X94,

0X93,0X93,0X93,0X93,0X92,0X92,0X92,0X92,0X91,0X91,0X91,0X91,0X90,0X90,0X90,0X90,

0X8f,0X8f,0X8f,0X8f,0X8e,0X8e,0X8e,0X8e,0X8d,0X8d,0X8d,0X8d,0X8c,0X8c,0X8c,0X8c,

0X8b,0X8b,0X8b,0X8b,0X8a,0X8a,0X8a,0X8a,0X89,0X89,0X89,0X89,0X88,0X88,0X88,0X88,

0X87,0X87,0X87,0X87,0X86,0X86,0X86,0X86,0X85,0X85,0X85,0X85,0X84,0X84,0X84,0X84,

0X83,0X83,0X83,0X83,0X82,0X82,0X82,0X82,0X81,0X81,0X81,0X81,0X80,0X80,0X80,0X80,

0X7f,0X7f,0X7f,0X7f,0X7e,0X7e,0X7e,0X7e,0X7d,0X7d,0X7d,0X7d,0X7c,0X7c,0X7c,0X7c,

0X7b,0X7b,0X7b,0X7b,0X7a,0X7a,0X7a,0X7a,0X79,0X79,0X79,0X79,0X78,0X78,0X78,0X78,

0X77,0X77,0X77,0X77,0X76,0X76,0X76,0X76,0X75,0X75,0X75,0X75,0X74,0X74,0X74,0X74,

0X73,0X73,0X73,0X73,0X72,0X72,0X72,0X72,0X71,0X71,0X71,0X71,0X70,0X70,0X70,0X70,

0X6f,0X6f,0X6f,0X6f,0X6e,0X6e,0X6e,0X6e,0X6d,0X6d,0X6d,0X6d,0X6c,0X6c,0X6c,0X6c,

0X6b,0X6b,0X6b,0X6b,0X6a,0X6a,0X6a,0X6a,0X69,0X69,0X69,0X69,0X68,0X68,0X68,0X68,

0X67,0X67,0X67,0X67,0X66,0X66,0X66,0X66,0X65,0X65,0X65,0X65,0X64,0X64,0X64,0X64,

0X63,0X63,0X63,0X63,0X62,0X62,0X62,0X62,0X61,0X61,0X61,0X61,0X60,0X60,0X60,0X60,

0X5f,0X5f,0X5f,0X5f,0X5e,0X5e,0X5e,0X5e,0X5d,0X5d,0X5d,0X5d,0X5c,0X5c,0X5c,0X5c,

0X5c,0X5b,0X5b,0X5b,0X5b,0X5a,0X5a,0X5a,0X5a,0X59,0X59,0X59,0X59,0X58,0X58,0X58,

0X58,0X57,0X57,0X57,0X57,0X56,0X56,0X56,0X56,0X55,0X55,0X55,0X55,0X54,0X54,0X54,

0X54,0X53,0X53,0X53,0X53,0X52,0X52,0X52,0X52,0X51,0X51,0X51,0X51,0X50,0X50,0X50,

0X50,0X4f,0X4f,0X4f,0X4f,0X4e,0X4e,0X4e,0X4e,0X4d,0X4d,0X4d,0X4d,0X4c,0X4c,0X4c,

0X4c,0X4b,0X4b,0X4b,0X4b,0X4a,0X4a,0X4a,0X4a,0X49,0X49,0X49,0X49,0X48,0X48,0X48,

0X48,0X47,0X47,0X47,0X47,0X46,0X46,0X46,0X46,0X45,0X45,0X45,0X45,0X44,0X44,0X44,

0X44,0X43,0X43,0X43,0X43,0X42,0X42,0X42,0X42,0X41,0X41,0X41,0X41,0X40,0X40,0X40,

0X40,0X3f,0X3f,0X3f,0X3f,0X3e,0X3e,0X3e,0X3e,0X3d,0X3d,0X3d,0X3d,0X3c,0X3c,0X3c,

0X3c,0X3b,0X3b,0X3b,0X3b,0X3a,0X3a,0X3a,0X3a,0X39,0X39,0X39,0X39,0X38,0X38,0X38,

0X38,0X37,0X37,0X37,0X37,0X36,0X36,0X36,0X36,0X35,0X35,0X35,0X35,0X34,0X34,0X34,

0X34,0X33,0X33,0X33,0X33,0X32,0X32,0X32,0X32,0X31,0X31,0X31,0X31,0X30,0X30,0X30,

0X30,0X2f,0X2f,0X2f,0X2f,0X2e,0X2e,0X2e,0X2e,0X2d,0X2d,0X2d,0X2d,0X2c,0X2c,0X2c,

0X2c,0X2b,0X2b,0X2b,0X2b,0X2a,0X2a,0X2a,0X2a,0X29,0X29,0X29,0X29,0X28,0X28,0X28,

0X28,0X27,0X27,0X27,0X27,0X26,0X26,0X26,0X26,0X25,0X25,0X25,0X25,0X24,0X24,0X24,

0X24,0X23,0X23,0X23,0X23,0X22,0X22,0X22,0X22,0X21,0X21,0X21,0X21,0X20,0X20,0X20,

0X20,0X1f,0X1f,0X1f,0X1f,0X1e,0X1e,0X1e,0X1e,0X1d,0X1d,0X1d,0X1d,0X1c,0X1c,0X1c,

0X1c,0X1b,0X1b,0X1b,0X1b,0X1a,0X1a,0X1a,0X1a,0X19,0X19,0X19,0X19,0X19,0X18,0X18,

0X18,0X17,0X17,0X17,0X17,0X16,0X16,0X16,0X16,0X15,0X15,0X15,0X15,0X14,0X14,0X14,

0X14,0X14,0X13,0X13,0X13,0X13,0X12,0X12,0X12,0X11,0X11,0X11,0X11,0X10,0X10,0X10,

0X10,0X10,0X0f,0X0f,0X0f,0X0f,0X0e,0X0e,0X0e,0X0e,0X0d,0X0d,0X0d,0X0d,0X0c,0X0c,

0X0c,0X0b,0X0b,0X0b,0X0b,0X0b,0X0a,0X0a,0X0a,0X0a,0X09,0X09,0X09,0X09,0X08,0X08,

0X08,0X08,0X07,0X07,0X07,0X06,0X06,0X06,0X06,0X06,0X05,0X05,0X05,0X05,0X04,0X04,

0X04,0X04,0X03,0X03,0X03,0X03,0X02,0X02,0X02,0X01,0X01,0X01,0X01,0X01,0X01,0X01,

0X01,0X01,0X01,0X01,0X01,0X01,0X01,0X02,0X02,0X02,0X03,0X03,0X03,0X03,0X04,0X04,

0X04,0X04,0X05,0X05,0X05,0X05,0X06,0X06,0X06,0X06,0X07,0X07,0X07,0X07,0X08,0X08,

0X08,0X08,0X09,0X09,0X09,0X09,0X0a,0X0a,0X0a,0X0a,0X0b,0X0b,0X0b,0X0b,0X0c,0X0c,

0X0c,0X0c,0X0d,0X0d,0X0d,0X0d,0X0e,0X0e,0X0e,0X0e,0X0f,0X0f,0X0f,0X0f,0X10,0X10,

0X10,0X10,0X11,0X11,0X11,0X11,0X12,0X12,0X12,0X12,0X13,0X13,0X13,0X13,0X14,0X14,

0X14,0X14,0X15,0X15,0X15,0X15,0X16,0X16,0X16,0X16,0X17,0X17,0X17,0X17,0X18,0X18,

0X18,0X18,0X19,0X19,0X19,0X19,0X1a,0X1a,0X1a,0X1a,0X1b,0X1b,0X1b,0X1b,0X1c,0X1c,

0X1c,0X1c,0X1d,0X1d,0X1d,0X1d,0X1e,0X1e,0X1e,0X1e,0X1f,0X1f,0X1f,0X1f,0X20,0X20,

0X20,0X20,0X21,0X21,0X21,0X21,0X22,0X22,0X22,0X22,0X23,0X23,0X23,0X23,0X24,0X24,

0X24,0X24,0X25,0X25,0X25,0X25,0X26,0X26,0X26,0X26,0X27,0X27,0X27,0X27,0X28,0X28,

0X28,0X28,0X29,0X29,0X29,0X29,0X2a,0X2a,0X2a,0X2a,0X2b,0X2b,0X2b,0X2b,0X2c,0X2c,

0X2c,0X2c,0X2d,0X2d,0X2d,0X2d,0X2e,0X2e,0X2e,0X2e,0X2f,0X2f,0X2f,0X2f,0X2f,0X30,

0X30,0X30,0X31,0X31,0X31,0X31,0X32,0X32,0X32,0X32,0X32,0X33,0X33,0X33,0X33,0X34,

0X34,0X34,0X34,0X35,0X35,0X35,0X35,0X36,0X36,0X36,0X36,0X37,0X37,0X37,0X37,0X38,

0X38,0X38,0X38,0X39,0X39,0X39,0X39,0X3a,0X3a,0X3a,0X3a,0X3b,0X3b,0X3b,0X3b,0X3c,

0X3c,0X3c,0X3c,0X3d,0X3d,0X3d,0X3d,0X3e,0X3e,0X3e,0X3e,0X3f,0X3f,0X3f,0X3f,0X40,

0X40,0X40,0X40,0X41,0X41,0X41,0X41,0X42,0X42,0X42,0X42,0X43,0X43,0X43,0X43,0X44,

0X44,0X44,0X44,0X45,0X45,0X45,0X45,0X46,0X46,0X46,0X46,0X47,0X47,0X47,0X47,0X48,

0X48,0X48,0X48,0X49,0X49,0X49,0X49,0X4a,0X4a,0X4a,0X4a,0X4b,0X4b,0X4b,0X4b,0X4c,

0X4c,0X4c,0X4c,0X4d,0X4d,0X4d,0X4d,0X4e,0X4e,0X4e,0X4e,0X4f,0X4f,0X4f,0X4f,0X50,

0X50,0X50,0X50,0X51,0X51,0X51,0X51,0X52,0X52,0X52,0X52,0X53,0X53,0X53,0X53,0X54,

0X54,0X54,0X54,0X55,0X55,0X55,0X55,0X56,0X56,0X56,0X56,0X57,0X57,0X57,0X57,0X58,

0X58,0X58,0X58,0X59,0X59,0X59,0X59,0X5a,0X5a,0X5a,0X5a,0X5b,0X5b,0X5b,0X5b,0X5c,

0X5c,0X5c,0X5c,0X5d,0X5d,0X5d,0X5d,0X5e,0X5e,0X5e,0X5e,0X5f,0X5f,0X5f,0X5f,0X60,

0X60,0X60,0X60,0X61,0X61,0X61,0X61,0X62,0X62,0X62,0X62,0X63,0X63,0X63,0X63,0X64,

0X64,0X64,0X64,0X65,0X65,0X65,0X65,0X66,0X66,0X66,0X66,0X67,0X67,0X67,0X67,0X68,

0X68,0X68,0X68,0X69,0X69,0X69,0X69,0X6a,0X6a,0X6a,0X6a,0X6b,0X6b,0X6b,0X6b,0X6c,

0X6c,0X6c,0X6c,0X6d,0X6d,0X6d,0X6d,0X6e,0X6e,0X6e,0X6e,0X6f,0X6f,0X6f,0X6f,0X70,

0X70,0X70,0X70,0X71,0X71,0X71,0X71,0X72,0X72,0X72,0X72,0X73,0X73,0X73,0X73,0X74,

0X74,0X74,0X74,0X75,0X75,0X75,0X75,0X76,0X76,0X76,0X76,0X77,0X77,0X77,0X77,0X78,

0X78,0X78,0X78,0X79,0X79,0X79,0X79,0X7a,0X7a,0X7a,0X7a,0X7b,0X7b,0X7b,0X7b,0X7b,

0X7c,0X7c,0X7c,0X7c,0X7d,0X7d,0X7d,0X7d,0X7e,0X7e,0X7e,0X7e,0X7f,0X7f,0X7f,0X7f, };

delay(uchar d) {

while(--d); }

/**********判断忙标志,返回的是一个位BF**********/ bit lcd_busy(void) {

uchar bflag; rs=0; rw=1; _nop_(); e=1; _nop_();

lcd_bus=0xff; bflag=lcd_bus; e=0;

return(bit)(bflag&0x80); //BF=1 busy }

/*********写命令,有两个参数,第一个是要写的命令控制字,

第二个是用来控制是否进行忙标志的判断。

busyflag=1:判断;为 0:不判断****************/ void lcd_wrcmd(uchar cmd) {

while(lcd_busy()); lcd_bus=cmd; rs=0; rw=0;

_nop_(); e=1; _nop_(); _nop_(); e=0; }

/************向液晶片写数据***************/ void lcd_wrdata( uchar lcddata) {

while(lcd_busy()); lcd_bus=lcddata; rs=1; rw=0; _nop_(); e=1; _nop_(); _nop_(); e=0; }

void lcd_ini(void) {

lcd_wrcmd(0x38); delay(100);

lcd_wrcmd(0x0c); delay(100);

lcd_wrcmd(0x06); delay(100);

lcd_wrcmd(0x01); delay(100); }

uchar key() {

uchar keycode=0xff,temp,i; key_bus=0x0f; temp=key_bus&0x0f;

if(temp!=0x0f) //有键按下 { key_bus=0x7f; for(i=0;i<4;i++) { temp=key_bus&0x0f; if(temp==0x07) { keycode=i*4; break; } else if(temp==0x0b) { keycode=i*4+1; break; }

else if(temp==0x0d) { keycode=i*4+2; break; }

else if(temp==0x0e) { keycode=i*4+3; break; } key_bus=(key_bus>>1)|0x80; } while((key_bus&0x0f)!=0x0f) //等待释放 { key_bus=0x0f; } } return keycode; }

void display(uchar cmd,uchar code *str) {

uchar i=0; lcd_wrcmd(cmd);

while(str[i]!='\\0') { lcd_wrdata(str[i]); i++; } }

main() {

uint i; uchar tt;

uchar code str[]=\ en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom[i]; ce=1; lcd_ini();

temp = sin1[1]; lcd_wrcmd(0xc0); lcd_wrdata(0x30+temp/100); lcd_wrdata(0x30+temp/10); lcd_wrdata(0x30+temp); temp=sin1[44]; lcd_wrcmd(0xc4); lcd_wrdata(0x30+temp/100); lcd_wrdata(0x30+temp/10); lcd_wrdata(0x30+temp); display(0x80,str); en=1; while(1) { tt=key(); if(tt==0) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom1[i]; ce=1;en=1; } else if(tt==1) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom[i]; ce=1; en=1;

} else if(tt==2) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=(Rom[i]/2+Rom1[i]/2); ce=1; en=1; } else if(tt==3) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom[i]*Rom1[i]; ce=1; en=1; } else if(tt==4) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom[i]-Rom1[i]; ce=1; en=1; } } }

本文来源:https://www.bwwdw.com/article/irf.html

Top