Chào các bác
em nhờ các bác xem giúp em đoạn code bên dưới sao có nhiều kiến ở đâu bò vào
chán quá bác ah.
File mô phỏng proteus 7.5 sp3
nhân tiện các bác cho em hỏi luôn. em dùng LCD Font Maker 3.92,chưa đăng ký.
sau khi tạo font xong cứ có cái đường kẻ ở giữa(hay là chưa đăng ký nên nó bị như vậy)??? Bác nào biết chỉ giùm em mới.
em nhờ các bác xem giúp em đoạn code bên dưới sao có nhiều kiến ở đâu bò vào
chán quá bác ah.
File mô phỏng proteus 7.5 sp3
nhân tiện các bác cho em hỏi luôn. em dùng LCD Font Maker 3.92,chưa đăng ký.
sau khi tạo font xong cứ có cái đường kẻ ở giữa(hay là chưa đăng ký nên nó bị như vậy)??? Bác nào biết chỉ giùm em mới.
Code:
// *************** PHUONG PHAP QUET : QUET HANG ********************************
// **************** LINH KIEN CHINH : IC 74HC595, pic 16F, ********************************
//******************** KHAI BAO PHAN CUNG CHO VI DIEU KHIEN ********************
#include "16F877a.h"
#fuses NOLVP,NOWDT,PUT,HS,NOPROTECT,NOBROWNOUT
#use delay(clock=20000000)
#use fast_io(b)
#use fast_io(c)
#use fast_io(a)
#define sck1 pin_c3
#define data1 pin_c5
#define chot1 pin_c2
//==================== CAC BIEN DUNG TRONG CHUONG TRINH ========================
int8 const t=8;
int8 d0[t],d1[t],d2[t],d3[t],d4[t],d5[t],d6[t],d7[t];
int const font[] = {
/*------------------------------------------------------------------------------
; If font display distortion, please check Fonts format of setup.
; Source file / text :
; Width x Height (pixels) :24X8
; Font Format/Size : Monochrome LCD Fonts ,Horizontal scan ,Little endian order/24Byte
; Font make date : 5/28/2010 2:46:04 PM
------------------------------------------------------------------------------*/
0x00,0x00,0x00,0x2E,0x4C,0x3A,0x24,0x52,0x0A,0x24,0x52,0x3A,0xFF,0xFF,0xFF,0x24,
0x52,0x0A,0xEE,0x8C,0x39,0x00,0x00,0x00,
};
//khoang trang
//****************************************************
void display()
{ int8 l,m,x;
//dua 8*t bit ra cot ung voi hang 1
for(l=t;l>0;l--) // nap data moi vao 595 , 8*4 =32 bit
{
for(m=0;m<8;m++)
{
if (d0[l]>=128) // 128 =0b10000000 de khi xoay trai lay ra bit can dich
{output_high(data1);}
else {output_low(data1);}
rotate_left( &d0[l],1); // bat dau dua 8 bit cua d0[l] vao 595
output_high(sck1);
output_low(sck1);
}
}
output_low(pin_c4); //khong cho fep 74ls138
output_high(chot1); // dua data tu 595 ra cac cot
output_low(chot1);
output_b(0); //hang0
output_high(pin_c4); // cho fep quet hang
delay_us(1500);
//-------------------------------------------------------
for(l=t;l>0;l--) // nap data moi vao 595
{
for(m=0;m<8;m++)
{
if (d1[l]>=128)
{output_high(data1);}
else {output_low(data1);}
rotate_left( &d1[l],1);
output_high(sck1);
output_low(sck1);
}
}
output_low(pin_c4);
output_high(chot1);
output_low(chot1);
output_b(1);
output_high(pin_c4);
delay_us(1500);
//-------------------------------------------------------
for(l=t;l>0;l--) // nap data moi vao 595
{
for(m=0;m<8;m++)
{
if (d2[l]>=128)
{output_high(data1);}
else {output_low(data1);}
rotate_left( &d2[l],1);
output_high(sck1);
output_low(sck1);
}
}
output_low(pin_c4);
output_high(chot1);
output_low(chot1);
output_b(2);
output_high(pin_c4);
delay_us(1500);
//-------------------------------------------------------
for(l=t;l>0;l--) // nap data moi vao 595
{
for(m=0;m<8;m++)
{
if (d3[l]>=128)
{output_high(data1);}
else {output_low(data1);}
rotate_left( &d3[l],1);
output_high(sck1);
output_low(sck1);
}
}
output_low(pin_c4);
output_high(chot1);
output_low(chot1);
output_b(3);
output_high(pin_c4);
delay_us(1500);
//-------------------------------------------------------
for(l=t;l>0;l--) // nap data moi vao 595
{
for(m=0;m<8;m++)
{
if (d4[l]>=128)
{output_high(data1);}
else {output_low(data1);}
rotate_left( &d4[l],1);
output_high(sck1);
output_low(sck1);
}
}
output_low(pin_c4);
output_high(chot1);
output_low(chot1);
output_b(4);
output_high(pin_c4);
delay_us(1500);
//-------------------------------------------------------
for(l=t;l>0;l--) // nap data moi vao 595
{
for(m=0;m<8;m++)
{
if (d5[l]>=128) {output_high(data1);}
else {output_low(data1);}
rotate_left( &d5[l],1);
output_high(sck1); output_low(sck1);
}
}
output_low(pin_c4);
output_high(chot1);
output_low(chot1);
output_b(5);
output_high(pin_c4);
delay_us(1500);
//-------------------------------------------------------
for(l=t;l>0;l--) // nap data moi vao 595
{
for(m=0;m<8;m++)
{
if (d6[l]>=128) {output_high(data1);}
else {output_low(data1);}
rotate_left( &d6[l],1);
output_high(sck1); output_low(sck1);
}
}
output_low(pin_c4);
output_high(chot1);
output_low(chot1);
output_b(6);
output_high(pin_c4);
delay_us(1500);
//-------------------------------------------------------
for(l=t;l>0;l--) // nap data moi vao 595
{
for(m=0;m<8;m++)
{
if (d7[l]>=128) {output_high(data1);}
else {output_low(data1);}
rotate_left( &d7[l],1);
output_high(sck1);
output_low(sck1);
}
}
output_low(pin_c4);
output_high(chot1);
output_low(chot1);
output_b(7);
output_high(pin_c4);
delay_us(1500);
}
//================================= end ===========================================
void dich()
{ int y,z,i;
for(z=t-1;z>0;z--)
{ if(z==8)i=0 ;else i+=1;// CHU Y DEN Z, dich tu byte cao nhat cua mang, so lan dich Z > ? =byte cao nhat - cho so byte cua chu
d0[z]=font[i*1+0];
d1[z]=font[i*1+1];
d2[z]=font[i*1+2];
d3[z]=font[i*1+3];
d4[z]=font[i*1+4];
d5[z]=font[i*1+5];
d6[z]=font[i*1+6];
d7[z]=font[i*1+7];
};// lay data tu font vao cac hang de thuc hien dich boi lenh duoi,
for(y=0;y<52;y++)
{ // dich data cua hang 7 di t byte voi bit 0
shift_right(d7,t,0);// dich data cua hang 7 di t byte voi bit 0
shift_right(d6,t,0);
shift_right(d5,t,0);
shift_right(d4,t,0);
shift_right(d3,t,0);
shift_right(d2,t,0);
shift_right(d1,t,0);
shift_right(d0,t,0);
for(i=0;i<5;i++)
{display(); // goi chung trinh hien thi
}
}
}
//******************* CHUONG TRINH CHINH *********************
void main()
{ // tat ca dieu la chan ra
set_tris_b(0);
set_tris_a(0);
set_tris_c(0x00);
delay_ms(100);
while(1)
{dich();
delay_ms(100);
}
}
//============================== THE END ======================================
