|
硬件是74ls164控制行扫描,hc595级联控制列数据。字模取字方式是:16×16点阵,字的横向8点构成一字节,左边点在字节的低位,字符点阵四角按右上角→左上角→右下角→左下角取字。字静态显示没有问题。就是左移这个程序实现不了,现象是,一个字移完,下一个字移到一办,前一个字就突然跳成后一个字了。程序如下:
/*-----------------------------// Includes \\----------------------------------*/
#include <reg52.h>
#include <74HC595.H>
#include <74LS164.h>
#include <intrins.h>
typedef unsigned long uint32;
typedef unsigned int uint16;
typedef unsigned char uint8;
/*------------------// Hardware specific configuration \\----------------------*/
//端口定义
//控制管脚信号定义
//#define HC595_RCK_H HC595_RCK=1
//#define HC595_RCK_L HC595_RCK=0
//#define HC595_SRCK_H HC595_SRCK=1
//#define HC595_SRCK_L HC595_SRCK=0
uint8 BUFF[14];
//uint8 g_bSystemTime2Ms = 0 ;
//uint8 col ;
//uint8 disrow ;
/*此为16×16点阵中文字库文件,字的横向8点构成一字节,左边点在字节的高位,字符点阵四角
按左上角→右上角→左下角→右下角取字*/
//字体为黑色。程序中需用反码输出
uint8 code hzdot[7][16][2] = {
/*菜 CB2CB */
0x02,0x20,0x7F,0xFF,0x02,0x20,0x02,0x20,0x1F,0xFC,0x10,0x44,0x08,0x88,0x04,0x10,
0x00,0x80,0x7F,0xFE,0x01,0xC0,0x02,0xA0,0x0C,0x90,0x38,0x88,0x10,0x86,0x00,0x80,
/*鸟 CC4F1 */
0x00,0x40,0x00,0x20,0x0F,0xF8,0x08,0x08,0x08,0x48,0x0A,0x88,0x04,0x88,0x00,0x08,
0x3F,0xF8,0x20,0x00,0x20,0x00,0x2F,0xFF,0x20,0x00,0x20,0x00,0x14,0x00,0x08,0x00,
/*学 CD1A7 */
0x10,0x80,0x31,0x08,0x13,0x30,0x09,0x10,0x7F,0xFE,0x20,0x02,0x17,0xF1,0x02,0x00,
0x01,0x00,0x7F,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x40,0x00,0x80,
/*习 CCFB0 */
0x00,0x00,0x3F,0xFC,0x20,0x00,0x20,0x10,0x20,0x20,0x20,0xC0,0x28,0x80,0x26,0x00,
0x21,0x80,0x20,0x60,0x20,0x1C,0x20,0x08,0x20,0x00,0x24,0x00,0x28,0x00,0x10,0x00,
/*单 CB5A5 */
0x04,0x10,0x0C,0x60,0x02,0x20,0x1F,0xFC,0x10,0x84,0x1F,0xFC,0x10,0x84,0x10,0x84,
0x1F,0xFC,0x10,0x84,0x00,0x80,0x7F,0xFF,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,
/*片 CC6AC */
0x02,0x00,0x02,0x08,0x02,0x08,0x22,0x08,0x7F,0xF8,0x00,0x08,0x00,0x08,0x00,0x08,
0x0F,0xF8,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x04,0x08,0x04,0x08,0x02,0x08,0x01,
/*机 CBBFA */
0x00,0x08,0x1F,0x08,0x11,0x08,0x11,0x7F,0x11,0x08,0x11,0x08,0x11,0x1C,0x11,0x2C,
0x11,0x2A,0x11,0x0A,0x10,0x89,0x50,0x88,0x50,0x48,0x50,0x48,0x60,0x28,0x00,0x08
};
uint8 code Hang[16][2] = {
0xff,0xfe,0xff,0xfd,0xff,0xfb,0xff,0xf7,0xff,0xef,0xff,0xdf,0xff,0xbf,0xff,0x7f,
0xfe,0xff,0xfd,0xff,0xfb,0xff,0xf7,0xff,0xef,0xff,0xdf,0xff,0xbf,0xff,0x7f,0xff};
/****************把字模移入数组的子函数********************/
void loadoneline(uint8 words , uint8 disrow )
{
uint8 s;
for(s=0;s<7;s++) //s为要显示的数字+1
{
BUFF[2*s] = hzdot [ words + s ][ disrow ][ 0 ] ;
BUFF[2*s + 1] = hzdot [ words + s ][ disrow ][ 1 ] ;
}
}
uint8 two_onebyte ( uint8 h1 , uint8 h2 , uint8 lie )
{
uint8 temp , tempcol ;
if ( lie < 8 ) tempcol = lie; else tempcol = lie- 8 ;
temp = ( h1 >> tempcol )|( h2<<(8-tempcol ));
return temp;
}
/*******************发送一行的子函数************************/
void sendoneline( uint8 lie )
{
uint8 s;
uint8 inc ,temp0 ;
if ( lie < 8 ) inc = 0 ; else inc = 1 ;
for( s = 0 ; s <= 11 ; s ++ ) //s=2*要显示的数字-1
{
temp0 = two_onebyte( BUFF[s + inc +1 ],BUFF [ s + inc ] , lie );
Ser_IN( ~temp0 ) ; //8位列数据输出,低电平点亮。
}
}
/*****************************************************************************
//*****************************************************************************/
void delay_1us(void) //1us延时函数
{
_nop_ ;
}
void delay_nus(unsigned int n) //N us延时函数
{
unsigned int i=0;
for (i=0;i<n;i++)
delay_1us();
}
//*****************************************************************************
// 名称:main()
// 功能:MAIN Routine
// 入口:无
// 出口:无
// 说明:
//*****************************************************************************
void main( )
{
uint8 i ;
static uint8 word=0 , speed = 5;
uint8 col = 0 ,disrow ;
//Timer0Init() ;
while(1)
{
while ( col < 16 )
{
for ( i = 0 ; i < speed ; i ++ )
{
for ( disrow = 0 ; disrow < 16 ; disrow ++ )
{
loadoneline( word , disrow ) ;
sendoneline( col ) ;
Par_OUT_disable ( ) ; //并行输出禁止
sendoneline( col ) ;
Par_OUT_Enable ( ) ; //并行输出使能
Par_OUT( ) ;
LIE_SCAN( Hang[ disrow ][0]); //发送行选择数据,控制阳极
LIE_SCAN( Hang[ disrow ][1]); //发送行选择数据,控制阳极
delay_nus( 10 ) ;
}
}
col ++ ;
}
col = 0 ;
word ++ ;
if( word >=7)word = 0;//总字数
}
}
//*****************************************************************************/ |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|