vietnamese177
08-03-2012, 10:39 PM
#include <barie.h>
#use rs232(baud=9600,parity=n,xmit=pin_C6,rcv=pin_C7,bi ts=8)
#use fast_io(B)
#byte portB=0x06
#bit lade=portB.0
#bit tren=portB.7
#bit duoi=portB.6
#bit bit1=portB.1
#bit bit2=portB.2
#bit led_dung=portB.4
#bit led_len=portB.5
#bit led_xuong=portB.3
char command='0';// =0 dong barie,=1 mo barie
#INT_RDA
void Receive_isr()
{
command=getc();
}
void main()
{
set_tris_B(0b11000000);
bit1=0;
bit2=0;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
ENABLE_INTERRUPTS(INT_RDA);
ENABLE_INTERRUPTS(INT_RB);
enable_interrupts(global);
// TODO: USER CODE!!
// ban dau dong barie
delay_ms(1000);
led_xuong=0;
lade=0;
do// dong barie 01
{
bit1=0;
bit2=1;
}
while (duoi==1);
//dung 00
bit1=0;
bit2=0;
led_xuong=1;
led_dung=0;
lade=1;
loop:........
.....................
.......................các bác cho em hỏi đoạn code trên sai ở đâu ạ, e test trên proteus ổn, trên PIC thì đo tín hiệu đầu ra các chân RB0 đến RB7 của PIC thì trạng thái của nó ko giống như trong mô phỏng :(help me!
#use rs232(baud=9600,parity=n,xmit=pin_C6,rcv=pin_C7,bi ts=8)
#use fast_io(B)
#byte portB=0x06
#bit lade=portB.0
#bit tren=portB.7
#bit duoi=portB.6
#bit bit1=portB.1
#bit bit2=portB.2
#bit led_dung=portB.4
#bit led_len=portB.5
#bit led_xuong=portB.3
char command='0';// =0 dong barie,=1 mo barie
#INT_RDA
void Receive_isr()
{
command=getc();
}
void main()
{
set_tris_B(0b11000000);
bit1=0;
bit2=0;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
ENABLE_INTERRUPTS(INT_RDA);
ENABLE_INTERRUPTS(INT_RB);
enable_interrupts(global);
// TODO: USER CODE!!
// ban dau dong barie
delay_ms(1000);
led_xuong=0;
lade=0;
do// dong barie 01
{
bit1=0;
bit2=1;
}
while (duoi==1);
//dung 00
bit1=0;
bit2=0;
led_xuong=1;
led_dung=0;
lade=1;
loop:........
.....................
.......................các bác cho em hỏi đoạn code trên sai ở đâu ạ, e test trên proteus ổn, trên PIC thì đo tín hiệu đầu ra các chân RB0 đến RB7 của PIC thì trạng thái của nó ko giống như trong mô phỏng :(help me!