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 21-11-2012, 02:23 AM   #2
dtcn_112
Nhập môn đệ tử
 
Tham gia ngày: Nov 2012
Bài gửi: 2
:
còn đây là code
#include <16F877A.H>
#include <font_c.h>
#fuses NOWDT,HS,,NOPUT,NOPROTECT,NODEBUG,NOBROWNOUT,NOLVP ,NOCPD,NOWRT
#use delay(clock=20000000)
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#use fast_io(e)
#byte porta=0x05
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08
#byte porte=0x09

#BIT SDA =PORTA.0
#BIT SH_CP =PORTA.1
#BIT ST_CP =PORTA.3
INT32 i;
unsigned char a,b;
unsigned int e=0;
void data74hc595out()
{
ST_CP=0;ST_CP=1;
//output_low(pin_a3);output_high(pin_a3);
}
void napdulieu74hc595(unsigned char data)

{
unsigned char i;
for(i=8;i>0;i--)
{
SDA= ~((data>>(i-1))&(0x01));//(data>>(i-1))&(0x01)
SH_CP=0;SH_CP=1;
}
}

void display16x128(void)
{
for(b=0;b<16;b++)/*so hang la 16*/
{

for(a=0;a<16;a++)
{
napdulieu74hc595(_bvh_mspace BitmapData[e]);
e+=1;/*nap du 8 byte*/
if(e>255)e=0;
}
PORTC=PORTD=0x00;
data74hc595out();
if(i>32768)i=0x01;
PORTC=i/256;PORTD=i;
//delay_us();
i*=2;
}
}
void main(void)
{


i=0x01;
set_tris_a(0b000000);PORTA=0b100100;
set_tris_b(0b11111111);
set_tris_c(0b00000000);
set_tris_d(0b00000000);
set_tris_e(0b000);
PORTC=PORTD=PORTE=0x00;

while(TRUE)
{

display16x128();

}
}


đây là thư viện font_c.h
//================================================== ====================
// Bitmap Data Created by RTB (c) 2009 Bui Viet Hoang
// 16 x 64 pixels - Monochrome
// Vertical Scan Lines - Left to Right, Top to Bottom
//================================================== ====================

#ifndef BVH_BMP_SIZE
#define BVH_BMP_SIZE
#define BVH_BMP_WIDTH 16
#define BVH_BMP_HEIGHT 64
#endif // BVH_BMP_SIZE

#ifndef _bvh_mspace
#define _bvh_mspace // const // code // eeprom // etc...
#endif // _bvh_mspace

unsigned char const _bvh_mspace BitmapData[]= {

/*------------------------------------------------------------------------------
; If font display distortion, please check Fonts format of setup.
; Source file / text :LCD Font Maker
; Width x Height (pixels) :128X16
; Font Format/Size : Monochrome LCD Fonts ,Horizontal scan ,Big endian order/256Byte

------------------------------------------------------------------------------*/
//0x80,0x10,0x10,//Width pixels,Height pixels,Width bytes
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xCF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x67,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFC,0xFF,0xFF,0xFF,0xFF,0x77,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFE,0x7F,0xFF,0xFF,0xFF,0x7F,0xFF, 0xFF,0xF8,0xFC,0xF3,0x3C,0xFF,
0xFF,0xFF,0xFF,0xFF,0x3C,0x7C,0x71,0x9C,0xCF,0x3C, 0x1F,0xF0,0x7C,0xF3,0x3C,0xFF,
0xFE,0x1E,0x79,0xF1,0xFB,0xBC,0xA9,0x9C,0xCF,0x38, 0x0F,0xE7,0x3C,0xF3,0x3C,0xFF,
0xFC,0x0E,0x79,0xE0,0xF3,0x9C,0xD9,0x9C,0xCF,0x33, 0xFF,0xCF,0x9C,0x73,0x3C,0xFF,
0xF9,0xE6,0x79,0xCE,0x73,0x9C,0xD9,0x9C,0xC7,0x33, 0xFF,0x9F,0xCC,0x33,0x3C,0xFF,
0xF9,0xFE,0x79,0x9F,0x33,0x80,0x79,0x9C,0xC3,0x33, 0xFF,0x9F,0xcc,0x93,0x00 0xFF,
0xF9,0xFE,0x79,0x9F,0x33,0x9C,0xF9,0x9C,0xC9,0x33, 0xFF,0x80,0x0C,0xC3,0x00,0xFF,
0xF9,0xFE,0x01,0x80,0x33,0x9C,0xF9,0x9C,0xCC,0x33, 0xC7,0x80,0x0C,0xE3,0x3C,0xFF,
0xF9,0xFE,0x01,0x80,0x33,0x9C,0xF9,0x9C,0xCE,0x33, 0xCF,0x9F,0xCC,0xF3,0x3C,0xFF,
0xF9,0xF6,0x79,0x9F,0x33,0x9C,0xF9,0x9C,0xCF,0x33, 0xCF,0x9F,0xCC,0xF3,0x3C,0xFF,
0xF9,0xE6,0x79,0x9F,0x33,0x9C,0xF9,0x9C,0xCF,0x39, 0xCF,0x9F,0xCC,0xF3,0x3C,0xFF,
0xFC,0x0E,0x79,0x9F,0x38,0x3C,0xF9,0xC1,0xCF,0x3C, 0x0F,0x9F,0xCC,0xF3,0x3C,0xFF,
0xFE,0x1E,0x79,0x9F,0x3C,0x7C,0xF9,0xE3,0xCF,0x3E, 0x1F,0x9F,0xCC,0xF3,0x3C,0xFF,
};
dtcn_112 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à 04:04 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