亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

蟲蟲首頁| 資源下載| 資源專輯| 精品軟件
登錄| 注冊

您現在的位置是:蟲蟲下載站 > 資源下載 > 單片機編程 > 16 16點陣顯示漢字原理及顯示程序

16 16點陣顯示漢字原理及顯示程序

  • 資源大小:105 K
  • 上傳時間: 2013-11-18
  • 上傳用戶:zoebknxf
  • 資源積分:2 下載積分
  • 標      簽: 16 點陣顯示 漢字 顯示程序

資 源 簡 介

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

//-----

相 關 資 源

主站蜘蛛池模板: 安阳县| 乐至县| 宣恩县| 卓资县| 义马市| 石渠县| 罗山县| 河南省| 新巴尔虎左旗| 大邑县| 普宁市| 长阳| 天水市| 永胜县| 郎溪县| 长武县| 十堰市| 尤溪县| 凭祥市| 东源县| 黎城县| 宿州市| 聊城市| 宜都市| 山东省| 德格县| 茌平县| 仙游县| 新巴尔虎左旗| 亚东县| 广州市| 湛江市| 咸丰县| 成安县| 鄂伦春自治旗| 甘谷县| 建德市| 长治市| 宁德市| 德阳市| 邛崃市|