Các bác cho em hỏi chút. Em dùng timer0 của pic 16f676 tạo xung 125khz tại chân C0 mà chưa được. không biết em tính toán có sai gì không. Mong các bác giúp em với. Đây là code của em:
#include <16F676.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES PUT //Power Up Timer
#FUSES BANDGAP_HIGH
#FUSES RESERVED //Used to set the reserved FUSE bits
#use delay(clock=20000000)
#int_TIMER0
void TIMER0_isr(void)
{
output_toggle(PIN_C0);
setup_timer_0(236);
}
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
setup_timer_0(236);
set_tris_c(0x00);
while(true){
}
}
|