您的位置 首页 FPGA

点阵流水显现I_LOVE_YOU

*功能:点阵流水显示I_LOVE_YOU**时钟频率:内部4M**编译环境:ICC-AVR7.22**版本:1.0*#includeiom16v.h>#includemac…

* 功 能:点阵流水显现I_LOVE_YOU *
* 时钟频率:内部4M *
* 编译环境:%&&&&&%C-AVR7.22 *
* 版别:1.0 *

#include
#include
#define uint unsigned int
#define uchar unsigned char
#define OE_138_ON PORTC |= (1< //使能74hc138
#define OE_138_OFF PORTC &= ~(1<#define array_size 63

const uchar I_LOVE_YOU[]={0X00,0X44,0X44,0X7C,0X44,0X44,0X00,0X00,
0X44,0X7C,0X44,0X40,0X40,0X40,0X40,0X00,
0X38,0X44,0X44,0X44,0X44,0X44,0X38,0X00,
0X04,0X0C,0X34,0X40,0X20,0X1C,0X0C,0X04,
0X44,0X7C,0X4C,0X4C,0X5C,0X44,0X44,0X00,
0X04,0X0C,0X4C,0X74,0X4C,0X0C,0X04,0X00,
0X04,0X7C,0X44,0X40,0X40,0X44,0X7C,0X04
0X38,0X44,0X44,0X44,0X44,0X44,0X38,0X00,}; //显现数据

const uchar seg[]={0,1,2,3,4,5,6,7}; //选通位码
uchar buffer[]={0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00};

void main(void)
{
DDRA=0xFF;
PORTA=0xFF;
DDRB=0xFF;
PORTB=0xFF;
DDRC=0x80;
TCCR0=0X0D;
TCNT0=0X00;
OCR0=8;
TIMSK|=0X02;
TIFR|=0X02;
TCCR1A=0X00;
TCCR1B=0X0D;
OCR1A=2500;
TIMSK|=0X10;
TIFR|=0X10; //时钟0和时钟1的初始化,CTC形式
OE_138_ON;
SEI();
while(1)
{
};
}

uchar count=0;
uchar j=0;

#pragma interrupt_handler time0:20 time1:7
void time0(void) //选通显现的方位
{
PORTB=buffer[j];
PORTA=seg[j];
j++;
if(j==8)
{
j=0;
}
}

void time1(void) //将显现的数据送入缓冲数组
{
uchar i;
for(i=0;i<7;i++)
{
buffer[i]=buffer[i+1];
}
buffer[7]=I_LOVE_YOU[count];
count++;
if(count==array_size)
{
count=0;
}
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/fpga/264403.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部