ai biết thì chỉ cho em về bộ so sánh và PWM hai kênh cùng một lúc.
và cho em biết bắt đầu từ đâu và làm như thế nào?
Xin chân thành cảm ơn!
và cho em biết bắt đầu từ đâu và làm như thế nào?
Xin chân thành cảm ơn!
#include <16F877.h>
#INCLUDE<def_877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
int16 pulse;
#int_ccp1
void isr()
{
if (!bit_test(PORTB,0)){
output_high(PIN_b0);
}
else{
output_low(PIN_B0);}
CCP_1+=1000;
}
void main()
{
CHAR VALUE;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_ccp1(CCP_COMPARE_INT);
enable_interrupts(INT_CCP1);
enable_interrupts(GLOBAL);
pulse = 1000;
TRISB = 0;
PORTB = 0;
CCP_1 = PULSE;
set_timer1(0);
while(true);
}
#include <16F877a.h>
#INCLUDE<def_877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
int16 pulse;
//#int_ccp1
#int_ccp2
void isr()
{
if (!bit_test(PORTB,0))
{
output_high(PIN_B0);
}
else
{
output_low(PIN_B0);
}
// CCP_1+=1000;
CCP_2+=5000;
}
void main()
{
// CHAR VALUE;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_ccp2(CCP_COMPARE_INT);
enable_interrupts(INT_CCP2); //-> Cho phep ngat
enable_interrupts(GLOBAL);
pulse = 5000;
TRISB = 0;
PORTB = 0;
// CCP_1 = PULSE;
CCP_2 = PULSE;
// set_timer1(0);
set_timer1(0);
while(true);
}

Comment