PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > Cơ bản về vi điều khiển và PIC

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Bài Trong Ngày Vi điều khiển

Cơ bản về vi điều khiển và PIC Những bài hướng dẫn cơ bản nhất để làm quen với vi điều khiển PIC

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 20-11-2011, 03:03 PM   #1
phapdp
Đệ tử 1 túi
 
Tham gia ngày: Mar 2011
Bài gửi: 14
:
giúp em dịch đoạn code này với

#include <16F877A.h>
#include <def_877a.h>
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=8)
#include <font_ascii.c>

//===================Dinh nghia cac chan cho ket noi 74595================
#bit data = 0x05.1
#bit clk = 0x05.2
#bit latch = 0x05.0
#bit tt = 0x05.3

//=====================khai bao bien toan cuc==============================
int8 buff_disp[33];
int8 max_char;
int8 time=5;
int8 count=0;
int is = 0;
char dt[65];
//======================KHAI BAO CAC CHUONH TRINH CON======================
void send_2_595(int8 temp);
void display();
void copy_2_ram1(int8 index_char);
void copy_2_ram2(int8 index_char);
void luudata();
//================================================== =======================
#INT_RDA
Receive_isr()
{
char c;
c = getc();
putc(c);
if(c==2) { count =0; is =1; };
else
{
if(c==3)
{
is = 0; max_char = count+5; luudata();
}
else
{
if(is==1 && count<60) { dt[count] = c; count++;
}
}
}
//================================================== ============================
void luudata()
{
int i;
for(i=0;i<max_char-5;++i)
write_eeprom(i,dt[i]);
write_eeprom(i,32); write_eeprom(i+1,32); write_eeprom(i+2,32); write_eeprom(i+3,32); write_eeprom(i+4,32); write_eeprom(i+5,32); write_eeprom(i+6,32);
write_eeprom(0xff,max_char);
}
//===========Chuong trinh chinh============================================= ====
void main() {
int8 i,j;
enable_interrupts(int_rda); //thiet lap ngat noi tiep
enable_interrupts(GLOBAL); // thiet lap ngat toan cuc
//================================================== ============================
TRISA=0x00; // Thiet lap chan vao ra
TRISB=0x00;
delay_ms(10);


//================================================== ===========================
max_char = read_eeprom(0xff);
//==============Bat dau hoat dong chuong trinh chinh===========================


while(1)
{
for (i=0;i<=32;i++)
buff_disp[i]=0xff;
for (i=0;i<=max_char;i++)
{
j=read_eeprom(i)-32;
if (j<=51)
copy_2_ram1(j);
else
{
j=j-51;
copy_2_ram2(j);
}
}
}
}
//==========================END MAIN =========================================

// ====================== CAC CHUONG TRINH CON ===============================
//=======Gui du lieu theo duong noi tiep toi 595==============================
void send_2_595(int8 temp) {

int8 i;
clk=0;
for(i=0;i<32;i++)
{
if(i==temp)
data=0;
else data=1;
clk=1;
clk=0;
}

}
//=====================Chuong trinh con hien thi===============================
void display() {
int8 count;
int8 i;

for (i=0;i<=time;i++) //Toc do chu chay thay doi boi bien time
{

for(count=32;count>0;count--)
{
send_2_595(count-1);
PORTB = 0x00;
latch=1;
latch=0;
PORTB = buff_disp[count];
delay_us(20);
}
}
}

//========================Copy to Ram1=======================================
void copy_2_ram1(int8 index_char)
{
int8 i,j;

for (j=0;j<=5;j++)
{
for (i=32;i>0;i--)
buff_disp[i]= buff_disp[i-1];
buff_disp[0]=font[index_char].b[j];
display();
}
buff_disp[0]=0xff;
}
//==========================Copy to Ram 2=====================================
void copy_2_ram2(int8 index_char) {

int8 i,j;

for (j=0;j<=5;j++)
{
for (i=32;i>0;i--)
buff_disp[i]= buff_disp[i-1];
buff_disp[0]=font2[index_char].b[j];
display();
}
buff_disp[0]=0xff;
}
phapdp vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 


Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 08:24 PM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam