View Single Post
Old 15-02-2012, 11:24 PM   #1
mongdududaydien
Nhập môn đệ tử
 
Tham gia ngày: Sep 2011
Bài gửi: 1
:
Cần Giúp Về Pic 18F4550

Mình đang học về Pic8f4550, thầy của mình có ra bài tập là sử dụng bộ timer0 để cho các led ở các chân a0, b0, c0, d0, e0 nhấp nháy với thời gian là 1s! Mình đã tham khảo nhiều trên mạng mà không hiếu sao mình vẩn không thành công, mong đc các bạn giúp đở.
Đây là code của mình:


#include "D:\DO AN DO LUONG DIEU KHIEN TU DONG\baitap3\main.h"
int16 count=0;
int8 a=0;
#int_TIMER0
void TIMER0_isr(void)
{
++count;
clear_interrupt(int_timer0);
set_timer0(56);
if(count == 25000)
{ count =0;
a=~a;
}
}

void main()
{

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DIV_BY_16,255,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab

// TODO: USER CODE!!
set_tris_a(0);
set_tris_b(0);
set_tris_c(0);
set_tris_d(0);
set_tris_e(0);
set_timer0(56);
while(1)
{
output_a(a);
output_b(a);
output_c(a);
output_d(a);
output_e(a);
}

}
Hình Kèm Theo
File Type: jpg pic.jpg (193.0 KB, 5 lần tải)
File Kèm Theo
File Type: rar baitap3.rar (29.3 KB, 8 lần tải)
mongdududaydien vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn