16 16点阵显示汉字原理及显示程序
- 名称:16 16点阵显示汉字原理及显示程序
- 类型:单片机学习
- 授权方式:免费版
- 更新时间:10-10 20:48:56
- 下载要求:无需注册
- 下载次数:6410次
- 语言简体中文
- 大小:125 KB
- 推荐度:3 星级
16 16点阵显示汉字原理及显示程序
#include "config.h"
#define DOTLED_LINE_PORT PORTB
#define DOTLED_LINE_DDR DDRB
#define DOTLED_LINE_PIN PINB
#define DOTLED_LINE_SCKT PB1
#define DOTLED_LINE_SCKH PB5
#define DOTLED_LINE_SDA PB3
#define DOTLED_ROW_PORT PORTC
#define DOTLED_ROW_DDR DDRC
#define DOTLED_ROW_PIN PINC
#define DOTLED_ROW_A0 PC0
#define DOTLED_ROW_A1 PC1
#define DOTLED_ROW_A2 PC2
#define DOTLED_ROW_A3 PC3
#define DOTLED_ROW_E PC4
uint8 font[] = {
/*-- 调入了一幅图像:这是您新建的图像 --*/
/*-- 宽度x高度=16x16 --*/
0x00,0x00,0x00,0x00,0x08,0x38,0x18,0x44,0x08,0x44,0x08,0x04,0x08,0x08,0x08,0x10,
0x08,0x20,0x08,0x40,0x08,0x40,0x08,0x40,0x3E,0x7C,0x00,0x00,0x00,0x00,0x00,0x00
};
static void TransmitByte(uint8 byte);
static void SelectRow(uint8 row);
static void FlipLatchLine(void);
static void TransmitByte(uint8 byte)
{
uint8 i;
for(i = 0 ; i < 8 ; i ++)
{
if(byte & (1 << i))
{
DOTLED_LINE_PORT |= _BV(DOTLED_LINE_SDA);
}
else
{
DOTLED_LINE_PORT &= ~_BV(DOTLED_LINE_SDA);
}
//__delay_cycles(100);
DOTLED_LINE_PORT |= _BV(DOTLED_LINE_SCKH);
//__delay_cycles(100);
DOTLED_LINE_PORT &= ~_BV(DOTLED_LINE_SCKH);
//__delay_cycles(100);
}
}
static void SelectRow(uint8 row)
{
//row -= 1;
row |= DOTLED_ROW_PIN & 0xe0;
DOTLED_ROW_PORT = row;
}
static void FlipLatchLine(void)
{
DOTLED_LINE_PORT |= _BV(DOTLED_LINE_SCKT);
DOTLED_LINE_PORT &= ~_BV(DOTLED_LINE_SCKT);
}
void InitDotLedPort(void)
{
DOTLED_LINE_PORT &= ~(_BV(DOTLED_LINE_SCKT) | _BV(DOTLED_LINE_SCKH));
DOTLED_LINE_PORT |= _BV(DOTLED_LINE_SDA);
DOTLED_LINE_DDR |= _BV(DOTLED_LINE_SCKT) | _BV(DOTLED_LINE_SCKH) | _BV(DOTLED_LINE_SDA);
DOTLED_ROW_PORT |= 0x1f;
DOTLED_ROW_PORT &= 0xf0;
DOTLED_ROW_DDR |= 0x1f;
}
void EnableRow(boolean IsEnable)
{
if(IsEnable)
{
DOTLED_ROW_PORT &= ~_BV(DOTLED_ROW_E);
}
else
{
DOTLED_ROW_PORT |= _BV(DOTLED_ROW_E);
}
}
void PrintDotLed(uint8 * buffer)
{
uint8 i , tmp;
for(i = 0 ; i < 16 ; i ++)
{
tmp = *buffer ++;
TransmitByte(~tmp);
tmp = *buffer ++;
TransmitByte(~tmp);
SelectRow(i);
FlipLatchLine();
}
}
void main(void)
{
InitDotLedPort();
EnableRow(TRUE);
while(1)
{
PrintDotLed(font);
__delay_cycles(5000);
}
}
//----------------------------------------------------
config.h文件
#ifndef _CONFIG_H
#define _CONFIG_H
//#define GCCAVR
#define CPU_CYCLES 7372800L
#ifndef GCCAVR
#define _BV(bit) (1 << (bit))
#endif
#define MSB 0x80
#define LSB 0x01
#define FALSE 0
#define TRUE 1
typedef unsigned char uint8;
typedef unsigned int uint16;
typedef unsigned long uint32;
typedef unsigned char boolean;
#include <ioavr.h>
#include <inavr.h>
#include "dotled.h"
#endif
//-----
, 大小:125 KB《16 16点阵显示汉字原理及显示程序》相关下载
- 在百度中搜索相关下载:16 16点阵显示汉字原理及显示程序
- 在谷歌中搜索相关下载:16 16点阵显示汉字原理及显示程序
- 在soso中搜索相关下载:16 16点阵显示汉字原理及显示程序
- 在搜狗中搜索相关下载:16 16点阵显示汉字原理及显示程序
编辑推荐
- · 单片机实验简介
- · 单片机软硬件联合仿真解决方案
- · 单片机技术中的一些问题
- · 单片机技术问题(一)
- · 电容介绍
- · 单元电路图识图方法
- · 磁技术的新应用与展望
- · 常用DTMF,FSK解码集成电路
- · xe系列任你选
- · viterbi译码算法简介