⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3310_8key_431.bas

📁 对于MEGE16中nokia3310的测试程序
💻 BAS
字号:
'///////////////////////////////////////////////////////////////
'
'//////////////////////////////////////////////////////////////
$Device= m16 '使用mega16
$Stack = 32  '堆栈32字节
$Clock = 7.3728  ' 时钟4MHz
$ShiftIn Data=PORTB.5, Clock=PORTB.7,Msb  '申明一个简易SPI口
$ShiftOut Data=PORTB.5, Clock=PORTB.7,Msb  '申明一个简易SPI口
$GLCD Nokia3310, SCLK=PORTB.7, SDIN=PORTB.5, DC=PORTB.4, SCE=PORTB.3  '3310液晶连接定义
$Def RES=PORTB.6  '复位脚
$LeadChar=" ", Format(3,0)  '显示数据格式化
$Def SL = PORTB.4 '去74HC165锁存 
$Def led = PORTD.7 ' 去3310背光控制
Dim n_key As Byte   '保存按键键值
Dim n As Byte       '显示一个变量n好观察3310有没有运行
Dim x As Byte
Dim m As Byte
Dim F0HD As Flash Byte ' 英文字库F0HD
Dim dian As Flash Byte
Dim ya As Flash Byte
Dim Sclk1616HD As Flash Byte
'Dim Yaxis As Flash Byte

n_key=255
Set DDRB.4:Reset res: Nop 15: Set RES  '复位3310LCD
Set DDRD.7
Reset led   '点亮3310背光灯
GLcdInit    '初始化3310LCD
FontSet F0HD '选择字体
Contrast=n
Gcls
GLcd(0,5),"www.atmel.com" '显示一个字符串
ImgSet(0,0),dian
ImgSet(15,0),ya
'ImgSet(0,0),Yaxis
n=60
Do
Contrast=n
GLcd(0,3),"key=";n_key   '显示键值
GLcd(60, 0), n  ' 显示一个变量n好观察3310有没有运行
Incr n
If n>80 Then n=60
Reset SL
Set SL       ' 锁存74HC165
Reset DDRB.5  '将SDIN变为输入为读取74HC165做准备
'Set DDRB.7
n_key=ShiftIn  '获得键值
n_key=Not n_key
WaitMs 30
Set DDRB.5 '将SDIN变为输出为写3310LCD做准备

	'For x=0 To 255
		'GLcd(60, 0), x
		ImgSet(60, 2, m), Sclk1616HD
		Incr m
		If m>7 Then m=0
		WaitMs 30

Loop

$Include "C:\FastAVR\F0HD.bas"
$Include "C:\FastAVR\dian.bas"
$Include "C:\FastAVR\ya.bas"
$Include "C:\FastAVR\Sclk1616HD.bas"
'$Include "C:\FastAVR\Yaxis.bas"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -