PIC Vietnam

PIC Vietnam (http://www.picvietnam.com/forum/index.php)
-   Các ngôn ngữ lập trình khác (CCS C, HT PIC,...) (http://www.picvietnam.com/forum/forumdisplay.php?f=12)
-   -   Hoi ve Driver LCD 4 bit trong CCS??? (http://www.picvietnam.com/forum/showthread.php?t=4607)

dtdat1909 20-07-2009 12:36 PM

Hoi ve Driver LCD 4 bit trong CCS???
 
Khi tôi sử dụng các hàm trong file LCD.C như lcd_init();, lcd_putc.. thì tất cả các port khác của con pic6f877a không hoạt động.
mặc dù trong protues tôi mô phỏng vẫn ok.
Có ai biết về vấn đề này xin giúp dùm.thanks.
Mình đang dùng CCS C version 4.068

Đây là đoạn code:
Với chân D0 enable, D1 RS, D2 RW, D4-D7 LCD4-LCD7

Code:

#include "C:\Program Files\PICC\Projects\dandb.h"
#include <lcd.c>
//#define use_portb_lcd false
void main()
{
 
 
  setup_adc_ports(NO_ANALOGS);
  setup_adc(ADC_OFF);
  setup_psp(PSP_DISABLED);
  setup_spi(SPI_SS_DISABLED);
  setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
  setup_timer_1(T1_DISABLED);
  setup_timer_2(T2_DISABLED,0,1);
  setup_comparator(NC_NC_NC_NC);
  setup_vref(FALSE);
  set_tris_b(0x00);
  lcd_init();
 
  // TODO: USER CODE!!
  while(true)
  {
  lcd_putc("welcome");
  output_b(0xff);
  delay_ms(500);
  output_b(0x00);
  delay_ms(500);
  }
}


nguyenductu2310 20-07-2009 01:47 PM

Lcd_4bit
 
Em CODE sửa lại chút thôi.
Lưu ý sơ đồ mạch bạn nhé, đấu thiếu không chạy đâu.
"
Code:
Code:

#include <16f877a.h>
#include <lcd.c>
#fuses NOWDT,HS,PUT,NOPROTECT
#use delay(clock=20000000)

void main()
{
  setup_adc_ports(NO_ANALOGS);
  setup_adc(ADC_OFF);
  setup_psp(PSP_DISABLED);
  setup_spi(SPI_SS_DISABLED);
  setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
  setup_timer_1(T1_DISABLED);
  setup_timer_2(T2_DISABLED,0,1);
  setup_comparator(NC_NC_NC_NC);
  setup_vref(FALSE);
  set_tris_b(0x00);
  set_tris_d(0x00);
  output_b(0x00);
  output_d(0x00);
  lcd_init();
 
  // TODO: USER CODE!!
  while(true)
  {
  lcd_putc("welcome");
  output_b(0xff);
  delay_ms(500);
  output_b(0x00);
  delay_ms(500);
  }
}


dtdat1909 20-07-2009 04:25 PM

Ah, nó chạy được rùi. Có khi nào trình biên dịch bị lỗi không bạn. Lúc đầu mình cũng có lệnh set và lệnh output. Không thể hiểu nổi, cũng có thể tôi đặt câu lệnh không đúng vị trí. Thanks very much

tantme 04-06-2012 06:51 PM

mình muốn hiển thị dấu phẩy động thì viết như thế nào. mình ko biết thuật toán. hjx. mình viết bằng ccs. ai có chương trình thì cho mình xem với. mail: tantme@gmail.com. thanks


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

Tên diễn đàn: vBulletin Version 3.8.11
Được sáng lập bởi Đoàn Hiệp.
Copyright © PIC Vietnam