#include "pic.h"
#define bitset(var,bitno) ((var) |= 1 << (bitno))
#define bitclr(var,bitno) ((var) &= ~(1 << (bitno))
// Commands to control LCD Graphical Display
const int CMD_SET_CURSOR = 0x21; //SET CURSOR
const int CMD_TXHOME = 0x40; //SET TXT HM ADD
const int CMD_TXAREA = 0x41; //SET TXT AREA
const int CMD_GRHOME = 0x42; //SET GR HM ADD
const int CMD_GRAREA = 0x43; //SET GR AREA
const int CMD_OFFSET = 0x22; //SET OFFSET ADD
const int CMD_ADPSET = 0x24; //SET ADD PTR
const int CMD_SETDATA_INC = 0x0C0; //WRITE DATA AND INCREASE ADP
const int CMD_AWRON = 0x0B0; //SET AUTO WRITE MODE
const int CMD_AWROFF = 0x0B2; //RESET AUTO WRITE MODE
const int TEXT_NUM = 35;
// Text data "Graphical LCD T6963C for Multisim"
const char textTable[35] =
{ 0x27, 0x52, 0x41, 0x50, 0x48, 0x49, 0x43, 0x41, 0x4c, 0x00, \
0x2C, 0x23, 0x24, 0x00, 0x34, 0x16, 0x19, 0x16, 0x13, 0x23, \
0x00, 0x00, 0x00, 0x46, 0x4f, 0x52, 0x00, 0x2d, 0x55, 0x4c, \
0x54, 0x49, 0x53, 0x49, 0x4d };
// Set Port B as output pins
void SetPortBOutput(void)
{
PORTB = 0x00;
bitset(STATUS, RP0);
TRISB = 0X00;
bitclr(STATUS, RP0);
}
void SendCommand(char cmd)
{
SetPortBOutput();
PORTB = cmd;
PORTA = 0x0B; // Send write command ready to LCD (1011)
bitset(PORTA, 2);
}
void SendDataByte(char databyte)
{
SetPortBOutput();
PORTB = databyte;
PORTA = 0X0A; // Write data ready (1010)
bitset(PORTA, 2);
}
void SendData(char highbyte, char lowbyte)
{
SendDataByte(lowbyte);
SendDataByte(highbyte);
}
void init(void)
{
bitclr(STATUS, RP0); // Select Bank 0
PORTA = 0x00;
PORTB = 0x00;
bitset(STATUS, RP0); // Select Bank 1
OPTION_REG = 0x80; // Disable weak pull up resistors
TRISA = 0x00; // Set Port A pins to output mode
TRISA = 0x00; // Set Port B pins to output mode
bitclr(STATUS, RP0); // Select Bank 0
PORTA = 0x0F; // No commands ready
// Select display mode to graph + text, cursor off
SendCommand( 0x9C );
// Set graphic mode home address to 0x0000
SendData(0,0);
SendCommand(CMD_GRHOME);
// Set text mode home address to 0x2941
SendData(0x29, 0x41);
SendCommand(CMD_TXHOME);
// Set character mode to use OR, use internal CG
SendCommand(0x80);
}
// Write data in "textTable" array to be displayed
// on Graphical LCD display to LCD's internal RAM.
void DisplayLCDText(void)
{
int nIndex = 0;
SendData(0x29, 0x7D);
SendCommand(CMD_ADPSET);
SendCommand(CMD_AWRON);
for( nIndex = 0; nIndex<TEXT_NUM; nIndex++ )
{
SendDataByte(textTable[nIndex]);
}
SendCommand(CMD_AWROFF);
}
// Move text right starting at the start address on the LCD
// specified by startAddrHigh and startAddrLow a number
// of steps specified by numSteps.
void MoveTextRight(int startAddrHigh, int startAddrLow, int numSteps)
{
int nIndex = 0;
for( nIndex = 0; nIndex<numSteps; nIndex++ )
{
SendData(startAddrHigh, startAddrLow);
SendCommand(CMD_TXHOME);
startAddrLow--;
}
}
// Move text left starting at the start address on the LCD
// specified by startAddrHigh and startAddrLow a number
// of steps specified by numSteps.
void MoveTextLeft(int startAddrHigh, int startAddrLow, int numSteps)
{
int nIndex = 0;
for( nIndex=0; nIndex<numSteps; nIndex++ )
{
SendData(startAddrHigh, startAddrLow);
SendCommand(CMD_TXHOME);
startAddrLow++;
}
}
void main()
{
init();
DisplayLCDText();
while( 1 )
{
MoveTextRight(0x29, 0x41, 20);
MoveTextLeft(0x29, 0x2D, 20);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
数字电路的基础知识,基于Multisim-14.0,有截屏,有图片 数字电路是一种电子电路,用来处理数字信号(以离散值表示信息的信号),例如0和1。这些电路由数字逻辑门组成,逻辑门根据输入信号产生特定的输出信号。数字电路在计算机硬件、通信设备、数字信号处理等领域中得到广泛应用。 数字电路包括多种类型,其中最基本的是组合逻辑电路和时序逻辑电路。 组合逻辑电路:组合逻辑电路的输出仅依赖于当前输入信号的状态,而不受到过去输入信号状态的影响。常见的组合逻辑电路包括逻辑门、多路复用器、解码器等。 时序逻辑电路:时序逻辑电路的输出不仅依赖于当前输入信号,还受到时钟信号的控制。时序逻辑电路包括触发器、计数器、时序状态机等。 数字电路的设计涉及到数字逻辑、布尔代数、半导体器件等知识。数字电路的实现形式多样,可以通过传统的离散元件搭建,也可以在集成电路芯片上实现。 在现代技术中,数字电路与计算机体系结构、程序设计等密切相关,是构建计算机系统的基础。随着技术的发展,数字电路在各个领域的应用不断扩展,成为数字化时代不可或缺的一部分。
资源推荐
资源详情
资源评论
收起资源包目录
案例_第9章 基于NI Multisim 14的单片机仿真.zip (67个子文件)
案例_第9章 基于NI Multisim 14的单片机仿真
ex1
开关量的输入输出仿真电路.ms14 122KB
ex1
ex1
main.asm 175B
MAIN.LST 1KB
MAIN.HEX 56B
ex1.mcuprj 1KB
ex1.mcuws 301B
ex7
ex7
ex7_2
main.asm 10KB
ex7_2.mcuprj 2KB
main.HEX 2KB
main.LST 42KB
main.O 11KB
main.ERR 0B
ex7
startup.as 2KB
main.pre 8KB
main.asm 10KB
startup.rlf 5KB
funclist 263B
ex7.as 35KB
ex7.mcuprj 2KB
ex7.obj 10KB
startup.lst 4KB
main.p1 26KB
main.c 3KB
startup.obj 1KB
ex7.mcuws 423B
PIC16F84 LCD显示仿真电路.ms14 96KB
ex2
彩灯闪亮电路.ms14 54KB
ex2
ex2
startup.as 2KB
main.pre 6KB
ex2.obj 2KB
ex2.mcuprj 2KB
startup.rlf 5KB
funclist 54B
ex2.as 8KB
startup.lst 4KB
main.c 283B
startup.obj 1KB
ex2.mcuws 301B
ex4
ex4
ex4.mcuws 301B
ex4
main.asm 2KB
MAIN.LST 7KB
ex4.mcuprj 1KB
main-my.asm 945B
MAIN.HEX 234B
数制转换仿真电路.ms14 151KB
ex3
流水灯仿真电路.ms14 102KB
ex3
ex3.mcuws 301B
ex3
main_0.lst 24KB
ex3.sym 1KB
ex3.err 679B
ex3.mcuprj 2KB
ex3.map 3KB
main_0.rlf 30KB
main.sdb 5KB
main_0.obj 2KB
ex3.hxl 802B
ex3.omf 847B
main.c 45B
ex3.hex 754B
ex8
Write_Read_EEDATA
Write_Read_EEDATA
Write_Read_EEDATA.asm 3KB
Write_Read_EEDATA.ERR 0B
Write_Read_EEDATA.O 4KB
Write_Read_EEDATA.mcuprj 4KB
Write_Read_EEDATA.HEX 376B
Write_Read_EEDATA.LST 13KB
Write_Read_EEDATA.mcuws 371B
基于PIC16F84A的EEPROM读写仿真电路.ms14 302KB
共 67 条
- 1
资源评论
枫蜜柚子茶
- 粉丝: 6696
- 资源: 4871
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 整卷预览.mhtml
- MySQL是一种广泛使用的开源关系型数据库管理系统,它提供了丰富的SQL语句用于数据库的创建、查询、更新和管理 以下是一些常见的
- MySQL是一种广泛使用的开源关系型数据库管理系统,它提供了丰富的SQL语句用于数据库的创建、查询、更新和管理 以下是一些常见
- MySQL是一种广泛使用的开源关系型数据库管理系统,它提供了丰富的SQL语句用于数据库的创建、查询、更新和管理 以下是一些常见的
- 基于Javascript的结婚请帖设计源码 - Invitation
- mysql语句大全及用法
- mysql语句大全及用法
- mysql语句大全及用法
- MySQL是一种广泛使用的开源关系型数据库管理系统
- MySQL是一种广泛使用的开源关系型数据库管理系统
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功