PDA

View Full Version : hỏi bài toán nhỏ PIC6F877--LCD1602


anh_gioi
27-09-2008, 12:38 AM
bài toán đơn giản là: khi cấp mức cao vào capture (pin_RC2) 1 khoang thời gian nào đấy thì số giây đó được hiển thị trên LCD.em dùng timer1 để đếm khoảng thời gian đó:


#include "F:\NCKH 2009\PIC 16\count_timer2\count_timer2.h"
#include <lcd_lib_4bit.c>
#include <F:\NCKH 2009\PIC 16\count_timer2\def_877a.h>
float value;
void main()
{
trisd = 0x00;
trisc = 0x04;

LCD_init();
Printf(LCD_putchar,"gioi");

setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);

while(!input(pin_c2)) {} // Wait for senser output to go high;
set_timer1(0);
while(input(pin_c2)) {}
value = get_timer1();

LCD_putcmd(0xC0);
LCD_putchar(value);
LCD_putcmd(0xCb);
printf(LCD_putchar," giay");
}

khi mô phỏng thì không hiển thị giá trị "value" cần tìm?
không biết em sai ở chỗ nào? mong các anh chỉ giúp !!!

falleaf
27-09-2008, 02:39 AM
http://www.minhhaco.com/index.php?act=view&code=post&cid=9&id=10

Chúc vui

david
27-09-2008, 10:19 AM
Mình không dùng driver <lcd_lib_4bit.c> nhưng mình nghĩ bạn khai báo biến value là float là không ổn nếu muốn hiện thị lên LCd

anh_gioi
27-09-2008, 10:29 AM
t1: vậy tớ phải khai báo thế nào?
t2: t dùng chân capture và phải khai báo capture như thế nào nhỉ?
t3:hiển thị lên LCD thì em hiển thị được rồi nhưng giá trị cần tìm value thi không hiển thị lên ạ?
help me!!!!

anh_gioi
27-09-2008, 08:38 PM
#include "F:\NCKH 2009\PIC 16\count_timer2\count_timer2.h"
#include <lcd_lib_4bit.c>
#include <F:\NCKH 2009\PIC 16\count_timer2\def_877a.h>
int16 value;
#INT_TIMER0

void main()
{
setup_ccp1(CCP_CAPTURE_RE);
//setup_ccp1(CCP_CAPTURE_DIV_16);

enable_interrupts(INT_CCP1); // Setup interrupt on falling edge
enable_interrupts(GLOBAL);

trisd = 0x00;
trisc = 0x04;

LCD_init();
Printf(LCD_putchar,"gioi");

setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);

while(!input(pin_c2)) {} // Wait for senser output to go high;
set_timer1(0);
while(input(pin_c2)) {}
value = get_timer1();

LCD_putcmd(0xC0);
LCD_putchar(value);
//printf(LCD_putchar, value );
LCD_putcmd(0xCb);
printf(LCD_putchar," giay");

}


em đã khởi tạo capture rùi, nhưng vẫn chưa ổn cho lắm?????---> vẫn vậy.
help me!