PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > Các ngôn ngữ lập trình khác (CCS C, HT 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

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 25-07-2012, 04:33 PM   #1
sontvak42
Đệ tử 2 túi
 
sontvak42's Avatar
 
Tham gia ngày: May 2012
Bài gửi: 30
:
Lightbulb Giúp gỡ rối Ngắt RB!

Ai có thể giúp em gỡ rối phần ngắt RB này cái không ạ.!
Tại sao khi chương trình của em viết khi nó nhảy vào chương trình phục vụ ngắt thì lại không thực hiện ở phần case 2 nữa, màn hình LCD cũng bị treo luôn không làm cách nào khôi phục được.
Mong các pro giúp đỡ em với!
Em cám ơn nhiều.

Code :

#include <16F877A.h>
#include <def_877a.h>
#device adc=10
#FUSES NOWDT, XT, PUT, NOPROTECT, NODEBUG, BROWNOUT, NOLVP, NOCPD, WRT_50%
#use delay(clock=4000000)
#use fast_io(a)
#use fast_io(b)

#include <lcd_nokia3310.c>
int8 model;
float adc;

#int_RB
void RB_isr()
{
output_c(0xff);
model =model+1;
clear_interrupt(int_rb);
}



void main()
{
set_tris_a(0xff); // all input
set_tris_b(0xff);
// port_b_pullups(1); // treo tro port b
set_tris_c(0x00);
set_tris_d(0x00); // all output

enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);
ext_int_edge(0,H_to_L);
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_2);
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);

// TODO: USER CODE!!

model =1;


while(true)

{
nokia_init();
// if(RB7==0)
// model++;
if(model==3)
model =1;


switch (model)
{
case 1:
{

nokia_clear_screen();
adc = read_adc();
nokia_gotoxy(0,0);
printf(nokia_printchar,"ADC!");
nokia_gotoxy(17,2);
printf(nokia_printchar,"%4.3f",adc);
delay_us(10);
}
break;
case 2:
{

nokia_clear_screen();
nokia_gotoxy(17,2);
printf(nokia_printchar,"Interrupts");
delay_us(10);
}
break;
}
}
}
sontvak42 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à 09:25 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