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 29-12-2010, 10:25 PM   #1
darlink
Đệ tử 1 túi
 
Tham gia ngày: Nov 2010
Bài gửi: 17
:
giup em voi moi nguoi!

em viet chuong trinh dieu che xung cho PIC 16f877a nhung khi dua oscilloscope vo thi no chang co xung nao dua ra CPP1 va CPP2 ca, moi nguoi giup em voi!

#include <16F877A.h>
#device *=16
#fuses NOWDT,HS,NOPUT,NOPROTECT,NODEBUG,NOBROWNOUT,NOLVP, NOCPD,NOWRT //khai bao cac thiet dat cho PIC
#use delay(clock=20000000) //khai bao su dung thach anh 20MHz de su dung ham delay cua chuong trinh
/************************************************** ***********************************/
void main(){
unsigned char x;
set_tris_c(0xf9); //dat 2chan ccp_pwm la output con cac chan con lai la input
output_c(0);
output_b(0);
setup_timer_2(t2_div_by_16,255,16);//t2_div_by_16:bo chia tan cho 16 => moi lan dem se mat thoi gian la (4/f*16)
//tang den 255 thi reset=>timer 2 se tran` sau 255*4/f*16
//sau 16 lan tran timer 2 thi xay ra ngat=>sau 16*255*4/f*16 se xay ra ngat timer 2
//tong cong thoi gian~13ms
setup_ccp1(ccp_pwm);
setup_ccp2(ccp_pwm);
while(true){
while(x!=1023){
x++;
set_pwm1_duty(x);
set_pwm2_duty(x);
delay_us(2500);}
delay_ms(500);
while(x>0){
x--;
set_pwm1_duty(x);
set_pwm2_duty(x);
delay_us(2500);}
}
}
darlink 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:19 AM.


Đượ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