View Single Post
Old 18-11-2016, 12:02 PM   #1
oanhoanh830
Nhập môn đệ tử
 
Tham gia ngày: Nov 2016
Bài gửi: 1
:
[PIC16F873A] Thạch anh 20 Mhz

Chào các bác, mình đang học cách sử dụng VDK PIC để tạo xung PWM. Mình sử dụng thạch anh 20MHz để tạo dao động. Khi test trên Proteus thì chạy được nhưng khi cắm vào board thì không có tín hiệu gì. Bác nào giúp mình cảm ơn rất nhiều. Đây là code
Code:
#include <16F873a.h> 
#use delay(clock = 20000000) 
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //High speed Osc (> 4mhz)
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection

main() 
{ 
output_low(PIN_C1);   // Set CCP2 output low 
output_low(PIN_C2);   // Set CCP1 output low 

setup_ccp1(CCP_PWM);  // Configure CCP1 as a PWM 
setup_ccp2(CCP_PWM);  // Configure CCP2 as a PWM 

setup_timer_2(T2_DIV_BY_1, 49, 1);  // 100 KHz      
set_pwm1_duty(31);                    // 25% duty cycle on pin C2 
set_pwm2_duty(62);                    // 50% duty cycle on pin C1 
while(1);  // Prevent PIC from going to sleep  (Important !) 
}
oanhoanh830 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn