SlideShare a Scribd company logo
1 of 31
LCD demo cho microblaze 2 Sau đây là các bước thực hiện LCD demo cho microblaze.Tool : EDK 8.2Demo trên board ML403, tuy nhiên vẫn có thể thay đổi cho board Spartan3E StarterChú ý: Vài bước được thông qua ( để mặc định và ấn nút next) thay vì post hình đầy đủ.----------------------------------------------------------------------PHAN 1 : Setup hardware ----------------------------------------------------------------------1> Start XPS 8.2i2> Tạo thư mục chứa project This image has been resized. Click this bar to view the full image. The original image is sized 654x395 and weights 75KB. 3> Creat new base system4> Select Board (chú ý: một số board có nhiều revision khác nhau, nên chọn revison thích hợp)5> Chọn món ăn tùy vào túi tiền  6> Creat Custom hardware (lcd port) This image has been resized. Click this bar to view the full image. The original image is sized 678x517 and weights 107KB. This image has been resized. Click this bar to view the full image. The original image is sized 681x526 and weights 102KB. This image has been resized. Click this bar to view the full image. The original image is sized 680x525 and weights 122KB. This image has been resized. Click this bar to view the full image. The original image is sized 680x526 and weights 168KB. This image has been resized. Click this bar to view the full image. The original image is sized 679x525 and weights 152KB. This image has been resized. Click this bar to view the full image. The original image is sized 680x526 and weights 141KB. Sau khi hoàn tất các bước trên, XPS tạo ra các file có cấu trúc như sau:Phần hardware chứa trong thư mục pcores, bao gồm tên (lcd_port) gắn với version hardware chỉ định (lcd_port_v1_00_a)Phần software chứa trong thư mục drivers (sẽ được trình bày trong phần sau) 7> Edit custom hardwareSau khi thực hiện xong thao tác creat custom peipheral (dùng bus OPB), XPS tạo ra 2 file source vhdl bao gồm name.vhd và user_logic.vhd chứa trong thư mục vhdl8> Edit user_logic.vhdgoto hàng (khoảng 100) add user port theo hình sau: This image has been resized. Click this bar to view the full image. The original image is sized 733x131 and weights 37KB. XPS tạo thanh ghi 
slv_reg0
 cho truy xuất với customer ip core, trong trường hợp này ta gán cho port xuất lcdgoto hàng (khoảng 208-209) add code như hình sau This image has been resized. Click this bar to view the full image. The original image is sized 718x195 and weights 46KB. 9> Edit lcd_port.vhdgoto hàng (khoảng 119) add user port theo hình sau: This image has been resized. Click this bar to view the full image. The original image is sized 732x131 and weights 44KB. goto hàng (khoảng 388) map port This image has been resized. Click this bar to view the full image. The original image is sized 669x113 and weights 29KB. Xong bước creat , edit customer OPB port 10> Import custom hardwareTrên tool bar : Hardware -> Creat or import peripheral This image has been resized. Click this bar to view the full image. The original image is sized 678x526 and weights 126KB. Đặt tên lcd_port This image has been resized. Click this bar to view the full image. The original image is sized 683x524 and weights 114KB. Chọn yes for overwrite This image has been resized. Click this bar to view the full image. The original image is sized 678x523 and weights 65KB. Check radio cho mục file .pao, browse đến đường dẫn thư mục hardware chứa file này This image has been resized. Click this bar to view the full image. The original image is sized 679x524 and weights 114KB. This image has been resized. Click this bar to view the full image. The original image is sized 682x525 and weights 191KB. This image has been resized. Click this bar to view the full image. The original image is sized 679x520 and weights 119KB. This image has been resized. Click this bar to view the full image. The original image is sized 680x526 and weights 94KB. This image has been resized. Click this bar to view the full image. The original image is sized 677x526 and weights 84KB. This image has been resized. Click this bar to view the full image. The original image is sized 680x521 and weights 96KB. 11> Add ipcore vào bus OBPTrên tab IP Catalog chọn Project Repository, click chuột phải vào lcd_port chọn add IPTrên mục system assembly view ta thấy custom ip core lcd_port_0 được add vào, lúc này lcd_port_0 chưa thật sự được gắn vào bus OPB, ta thực hiện bước connect vào OPB theo hình sau:Chọn nút radio của mục port , connection filters chọn all để hiển thị tất cả các đường kết nối.OPB_clk -> sys_clk_s : system clock sourcelcd_port_pin -> Make external This image has been resized. Click this bar to view the full image. The original image is sized 658x217 and weights 67KB. This image has been resized. Click this bar to view the full image. The original image is sized 642x143 and weights 44KB. Sau khi kết nối lcd_port_pin với external port, mục trên cùng External Ports xuất hiện đường kết nối lcd_port_0_lcd_port_pin, rename phần tên kết nối phía bên trái để tiện cho việc assign pin constrain.Chọn nút radio address, trong mục size (kích thước vùng nhớ cho ngoại vi) trong drop list chọn 64K, sau đó chọn Generate Addresses, Xillin tự động tính toán các đường địa chỉ và remap lại cho toàn bộ ngoại vi. This image has been resized. Click this bar to view the full image. The original image is sized 788x210 and weights 73KB. Cuối cùng là bước assign constrain pins cho lcd_port, tùy theo kết nối của các board khác nhau ta có các khai báo gán pins khác nhau. This image has been resized. Click this bar to view the full image. The original image is sized 800x370 and weights 161KB. Tool -> Hardware -> Generate Bitstream. Đến bước này ta có thể thong thả ngồi uống Coca chờ đợi XPS hoàn tất cho phần hardware. Phần trước giới thiệu xong phần import customer hadware, phần này giới thiệu về driver cho LCD.Sau khi import lcd_port vào bus hệ thống, XPS tự động tạo ra thư viện hỗ trợ cho việc phát triển phần mềm. Ngoài ra các file hệ thống cũng được cập nhật.file: system.mhs Code: BEGIN lcd_port PARAMETER INSTANCE = lcd_port_0 PARAMETER HW_VER = 1.00.a PARAMETER C_BASEADDR = 0x77400000 PARAMETER C_HIGHADDR = 0x7740ffff BUS_INTERFACE SOPB = mb_opb PORT lcd_port_pin = lcd_port_0_lcd_port_pin PORT OPB_Clk = sys_clk_s END file: system.mss Code: BEGIN DRIVER PARAMETER DRIVER_NAME = lcd_port PARAMETER DRIVER_VER = 1.00.a PARAMETER HW_INSTANCE = lcd_port_0 END Driver được tạo ra trong đường dẫn : ...drivers/lcd_port_v1_00_a/src//lcd_port.c/lcd_port.h/lcd_port_selftest.c/Makefile File lcd_port_selftest.c được tạo ra cho việc test thanh ghi reg0 (lcd_port), ta có thể tham khảo, sữa chữa tùy vào mục đích xử dụng.Các prototype cho các hàm truy xuất thanh ghi được khai báo trong lcd_port.hSau đây là các bước tạo project mới dùng công cụ phát triển phần mềm SDK của xilinx.1> Trên tool bar của XPS:Chọn Software -> Lauch Platform Studio SDK2> Trong hộp thoại Application Wizard:Chọn Creat a New SDK Application Project -> Next3> Trong mục New ProjectĐặt tên project -> Next Lấy thông số mặc định Xilinx MicroBlaze Executable -> NextFinish thao tác create new project Sau khi hoàn tất các bước trên xilinx tự động tạo các thư mục và các file trong thư mục có tên project name, và một danh sách các thư viện có liên quan đến microblaze. This image has been resized. Click this bar to view the full image. The original image is sized 726x423 and weights 140KB. 4> Tạo Linker Script :Trong mục Navigator, click chuột phải lcd_disp -> Gnenerate Linker Script... This image has been resized. Click this bar to view the full image. The original image is sized 799x483 and weights 163KB. Trong crop down list chọn DDRAM, dùng làm vùng nhớ data , text ...6> Creat New Source fileClick vào biểu tượng C+ trên tool barĐặt tên file lcd.cĐể viết chương trình giao tiếp lcd, tức là dùng microblaze xuất tín hiệu điều khiển lên port_lcd, ngoài lcd_port còn có các ngoại vi khác. Microblaze là processor có cấu trúc tổ chức bộ nhớ Havard, Vùng Intruction và vùng IO, memory nằm riêng biệt. Các IO được truy xuất thông qua địa chỉ, mỗi IO chiếm một vùng nhớ có tầm từ C_BASEADDR - C_HIGHADDR. Các base add được cập nhật trong file system.mhs sau khi thực hiện thao tác Generate Address trong mục trình bày trên. Ta có thể tham khảo C_BASEADDR thông qua bước sau:Trong XPS -> System Essembly View -> chọn IO -> click chuột phải -> Conigure IP ... This image has been resized. Click this bar to view the full image. The original image is sized 629x438 and weights 69KB. Và địa chỉ đầu tiên 0x77400000 được dùng cho việc truy xuất thanh ghi reg0 (Do phần creat custom hardware ta chọn option cho 1 thanh ghi, trong trường hợp tạo nhiều thanh ghi, ví dụ như reg0, reg1, reg2 thì địa chỉ truy xuất các thanh ghi này sẽ lần lượt là C_BASEADDR,C_BASEADDR+0x04,C_BASEADDR +0x08...) This image has been resized. Click this bar to view the full image. The original image is sized 800x461 and weights 234KB. Hàm LCD_PORT_mWriteSlaveReg0(LCD_PORT_BASE_ADDR, (value)) được định nghĩa sẵn bởi Xilinx, ghi giá trị 
value
 ra lcd_port.7> Edit lcd.cCông việc kế tiếp là soạn thảo code điểu khiển LCD, hầu hết các board FPGA đều thiết kế cho việc giao tiếp mode 4 bit. Trong phần thiết kế này dùng 1 port xuất để điểu khiển, lcd_port<6:0> <-> (E, RW,RS,D7,D6,D5,D4) This image has been resized. Click this bar to view the full image. The original image is sized 799x460 and weights 208KB. Code: ////////////////////////////////////////////////////////////////////////////// // Filename:          lcd.c // Version:           1.00.a // Description:       lcd_port Driver Source File // Date:              21/09/2007 ////////////////////////////////////////////////////////////////////////////// /***************************** Include Files *******************************/ #include 
lcd_port.h
 #include 
string.h
 /************************* Constant Definitions ****************************/ #define LCD_PORT_BASE_ADDR  0x77400000 /************************* Macro Definitions *******************************/ #define LCD_PORT_WRITE(value)br />LCD_PORT_mWriteSlaveReg0(LCD_PORT_BASE_ADDR, (value)) /************************************************************************** /* @Function name   : wait_us() /* Description      : wait n micro seconds /* Argument         : unsigned int n /* Return value     : void /* Author           : Kamejoko80 /* Date             : 21/09/2007 **************************************************************************/ void wait_us(unsigned int n) { unsigned int i,j; for(i=1;i<=n;i++) { for(j=1;j<=50;j++) { } } } /************************************************************************** /* @Function name   : write_lcd_reg() /* Description      : write lcd command /* Argument         : char value /* Return value     : void /* Author           : Kamejoko80 /* Date             : 21/09/2007 **************************************************************************/ void write_lcd_reg(char value) { char temp; temp = (value>>4)&0x0F;     /* get nibble high   */ LCD_PORT_WRITE(temp);       /* write to lcd port */ wait_us(1); LCD_PORT_WRITE(temp|0x40);  /* E=1               */ wait_us(1); LCD_PORT_WRITE(temp);       /* E=0               */ wait_us(2); temp = value&0x0F;          /* get nibble low    */ LCD_PORT_WRITE(temp);       /* write to lcd port */ wait_us(1); LCD_PORT_WRITE(temp|0x40);  /* E=1               */ wait_us(1); LCD_PORT_WRITE(temp);       /* E=0               */ wait_us(2); } /************************************************************************** /* @Function name   : write_lcd_reg() /* Description      : write lcd command /* Argument         : char value /* Return value     : void /* Author           : Kamejoko80 /* Date             : 21/09/2007 **************************************************************************/ void write_lcd_data(char value) { char temp; temp = (value>>4)&0x0F;     /* get nibble high   */ temp |= 0x10;               /* RS=1              */ LCD_PORT_WRITE(temp);       /* write to lcd port */ wait_us(2); LCD_PORT_WRITE(temp|0x40);  /* E=1               */ wait_us(2); LCD_PORT_WRITE(temp);       /* E=0               */ wait_us(4); temp = value&0x0F;          /* get nibble low    */ temp |= 0x10;               /* RS=1              */ LCD_PORT_WRITE(temp);       /* write to lcd port */ wait_us(2); LCD_PORT_WRITE(temp|0x40);  /* E=1               */ wait_us(2); LCD_PORT_WRITE(temp);       /* E=0               */ wait_us(40); } /************************************************************************** /* @Function name   : lcd_mode_init() /* Description      : 4 bit mode initialization /* Argument         : void /* Return value     : void /* Author           : Kamejoko80 /* Date             : 21/09/2007 **************************************************************************/ void lcd_mode_init(void) { wait_us(10000);      /* waits 10ms     */ write_lcd_reg(0x18); /* set 8 bit mode */ wait_us(5000); write_lcd_reg(0x18); /* set 8 bit mode */ wait_us(500); write_lcd_reg(0x18); /* set 8 bit mode */ wait_us(40); write_lcd_reg(0x08); /* set 4 bit mode */ wait_us(40); write_lcd_reg(0x28); /* set 2 lines    */ wait_us(40); write_lcd_reg(0x08); /* display off    */ wait_us(40); write_lcd_reg(0x01); /* clear display  */ wait_us(2000); write_lcd_reg(0x06); /* entry mode     */ wait_us(40); write_lcd_reg(0x0C); /* display on     */ wait_us(10000);      /* waits 10ms     */ } /************************************************************************** /* @Function name   : lcd_clr_disp() /* Description      : clear display & cursor home /* Argument         : void /* Return value     : void /* Author           : Kamejoko80 /* Date             : 21/09/2007 **************************************************************************/ void lcd_clr_disp(void) { write_lcd_reg(0x01); /* clear lcd    */ wait_us(2000); write_lcd_reg(0x02); /* cursor home  */ wait_us(2000); } /************************************************************************** /* @Function name   : lcd_line_feed() /* Description      : goto 2th line /* Argument         : void /* Return value     : void /* Author           : Kamejoko80 /* Date             : 21/09/2007 **************************************************************************/ void lcd_line_feed() { write_lcd_reg(0x80|0x40); /* goto line 2  */ wait_us(40); } /************************************************************************** /* @Function name   : lcd_print_str() /* Description      : lcd print string /* Argument         : char *s /* Return value     : void /* Author           : Kamejoko80 /* Date             : 21/09/2007 **************************************************************************/ void lcd_print_str(char *s) { int i=0; while(i,[object Object]
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze
L C D Demo Cho Microblaze

More Related Content

Similar to L C D Demo Cho Microblaze

Ac fr ogdyeeau50afg7bcxmtrplolcc9hoeu__6mus7monefoq946imlse7fvjnynphogvjyelfq...
Ac fr ogdyeeau50afg7bcxmtrplolcc9hoeu__6mus7monefoq946imlse7fvjnynphogvjyelfq...Ac fr ogdyeeau50afg7bcxmtrplolcc9hoeu__6mus7monefoq946imlse7fvjnynphogvjyelfq...
Ac fr ogdyeeau50afg7bcxmtrplolcc9hoeu__6mus7monefoq946imlse7fvjnynphogvjyelfq...Vuong Nguyen
 
1. Tai lieu S7-1200.pdf
1. Tai lieu S7-1200.pdf1. Tai lieu S7-1200.pdf
1. Tai lieu S7-1200.pdfHung353905
 
Tai lieu S7-1200.pdf
Tai lieu S7-1200.pdfTai lieu S7-1200.pdf
Tai lieu S7-1200.pdfMan_Ebook
 
1. tai lieu s7 1200
1. tai lieu s7 12001. tai lieu s7 1200
1. tai lieu s7 1200AM0709
 
418 giaotrinh avr
418 giaotrinh avr418 giaotrinh avr
418 giaotrinh avranhhoi12345
 
Giaotrinh avr tech24.vn
Giaotrinh avr tech24.vnGiaotrinh avr tech24.vn
Giaotrinh avr tech24.vnbibibobo2007
 
Utf8 giao trinh lr&sc
Utf8 giao trinh lr&scUtf8 giao trinh lr&sc
Utf8 giao trinh lr&scthungpin111
 
Giáo trình vi điều khiển avr
Giáo trình vi điều khiển avr Giáo trình vi điều khiển avr
Giáo trình vi điều khiển avr Ky Nguyen Ad
 
Android chapter 02 - Setup to emulator
Android chapter 02 - Setup to emulatorAndroid chapter 02 - Setup to emulator
Android chapter 02 - Setup to emulatorJustin Hoang
 
Thiết lập đồ họa cho DevC++(How to setup graphics environment in DevC++)
Thiết lập đồ họa cho DevC++(How to setup graphics environment in DevC++)Thiết lập đồ họa cho DevC++(How to setup graphics environment in DevC++)
Thiết lập đồ họa cho DevC++(How to setup graphics environment in DevC++)tiktiktc
 
Phanmemdangtindiendandiasao
PhanmemdangtindiendandiasaoPhanmemdangtindiendandiasao
Phanmemdangtindiendandiasaolanchi1323
 
Lập trình PLC S7 1200 tiếng Việt-Chuong 3 cấu hình thiết bị
Lập trình PLC S7 1200 tiếng Việt-Chuong 3 cấu hình thiết bịLập trình PLC S7 1200 tiếng Việt-Chuong 3 cấu hình thiết bị
Lập trình PLC S7 1200 tiếng Việt-Chuong 3 cấu hình thiết bịXuân Thủy Nguyễn
 
Trần Anh Khoa - Kautilya và Powershell trong kỹ thuật tấn công tiếp cận
Trần Anh Khoa - Kautilya và Powershelltrong kỹ thuật tấn công tiếp cậnTrần Anh Khoa - Kautilya và Powershelltrong kỹ thuật tấn công tiếp cận
Trần Anh Khoa - Kautilya và Powershell trong kỹ thuật tấn công tiếp cậnSecurity Bootcamp
 

Similar to L C D Demo Cho Microblaze (20)

Ac fr ogdyeeau50afg7bcxmtrplolcc9hoeu__6mus7monefoq946imlse7fvjnynphogvjyelfq...
Ac fr ogdyeeau50afg7bcxmtrplolcc9hoeu__6mus7monefoq946imlse7fvjnynphogvjyelfq...Ac fr ogdyeeau50afg7bcxmtrplolcc9hoeu__6mus7monefoq946imlse7fvjnynphogvjyelfq...
Ac fr ogdyeeau50afg7bcxmtrplolcc9hoeu__6mus7monefoq946imlse7fvjnynphogvjyelfq...
 
1. Tai lieu S7-1200.pdf
1. Tai lieu S7-1200.pdf1. Tai lieu S7-1200.pdf
1. Tai lieu S7-1200.pdf
 
Tai lieu S7-1200.pdf
Tai lieu S7-1200.pdfTai lieu S7-1200.pdf
Tai lieu S7-1200.pdf
 
1. tai lieu s7 1200
1. tai lieu s7 12001. tai lieu s7 1200
1. tai lieu s7 1200
 
Phu chuong
Phu chuongPhu chuong
Phu chuong
 
418 giaotrinh avr
418 giaotrinh avr418 giaotrinh avr
418 giaotrinh avr
 
Giaotrinh avr tech24.vn
Giaotrinh avr tech24.vnGiaotrinh avr tech24.vn
Giaotrinh avr tech24.vn
 
Utf8 giao trinh lr&sc
Utf8 giao trinh lr&scUtf8 giao trinh lr&sc
Utf8 giao trinh lr&sc
 
Giáo trình vi điều khiển avr
Giáo trình vi điều khiển avr Giáo trình vi điều khiển avr
Giáo trình vi điều khiển avr
 
Android chapter 02 - Setup to emulator
Android chapter 02 - Setup to emulatorAndroid chapter 02 - Setup to emulator
Android chapter 02 - Setup to emulator
 
Asm
AsmAsm
Asm
 
Quantriweb moi
Quantriweb moiQuantriweb moi
Quantriweb moi
 
Thiết lập đồ họa cho DevC++(How to setup graphics environment in DevC++)
Thiết lập đồ họa cho DevC++(How to setup graphics environment in DevC++)Thiết lập đồ họa cho DevC++(How to setup graphics environment in DevC++)
Thiết lập đồ họa cho DevC++(How to setup graphics environment in DevC++)
 
Đề tài: Dòng PLC hoạt động vô cùng hiệu quả công việc, HOT
Đề tài: Dòng PLC hoạt động vô cùng hiệu quả công việc, HOTĐề tài: Dòng PLC hoạt động vô cùng hiệu quả công việc, HOT
Đề tài: Dòng PLC hoạt động vô cùng hiệu quả công việc, HOT
 
Phanmemdangtindiendandiasao
PhanmemdangtindiendandiasaoPhanmemdangtindiendandiasao
Phanmemdangtindiendandiasao
 
Đề tài: Giao tiếp máy tính - VĐK sử dụng C# và VB, HAY, 9đ
Đề tài: Giao tiếp máy tính - VĐK sử dụng C# và VB, HAY, 9đĐề tài: Giao tiếp máy tính - VĐK sử dụng C# và VB, HAY, 9đ
Đề tài: Giao tiếp máy tính - VĐK sử dụng C# và VB, HAY, 9đ
 
Bien dich nhan linux
Bien dich nhan linuxBien dich nhan linux
Bien dich nhan linux
 
Lập trình PLC S7 1200 tiếng Việt-Chuong 3 cấu hình thiết bị
Lập trình PLC S7 1200 tiếng Việt-Chuong 3 cấu hình thiết bịLập trình PLC S7 1200 tiếng Việt-Chuong 3 cấu hình thiết bị
Lập trình PLC S7 1200 tiếng Việt-Chuong 3 cấu hình thiết bị
 
Vhdl
VhdlVhdl
Vhdl
 
Trần Anh Khoa - Kautilya và Powershell trong kỹ thuật tấn công tiếp cận
Trần Anh Khoa - Kautilya và Powershelltrong kỹ thuật tấn công tiếp cậnTrần Anh Khoa - Kautilya và Powershelltrong kỹ thuật tấn công tiếp cận
Trần Anh Khoa - Kautilya và Powershell trong kỹ thuật tấn công tiếp cận
 

L C D Demo Cho Microblaze

  • 1.