mình đã thử con master chỉ liên tục truyền và con slave liên tục nhận thì không có vấn đề gì. nhưng khi thực hiện hỏi đáp như trên thì ctr không chạy đc.
đây là đoạn code:
Code:
///////////////////////////////////////////////////////////////////
//ham nhan ky tu
#INT_RDA
void RECEIVER()
{
int k,l;
output_high(pin_b0);
recei[k]=fgetc(PC);
if (recei[k]=='@')
{
recei[k]=null;
if (recei[0]=='b')
{
output_high(pin_e0);//set chan dk
r232=0;//set co nhan
delay_ms(50);
}
k=0;
}
else
k=k+1;
}
/////////////////////////////////////////////////////////*/
void main(void)
{
int16 i,j;
//int1 r232;
set_tris_a(255);
set_tris_b(0);
set_tris_d(0);
set_tris_e(0);
portb=0;
output_high(pin_e0);
enable_interrupts(global);
enable_interrupts(int_RDA);
lcd_init();
delay_ms(1);
lcd_clear();
delay_ms(1);
r232=0;
while(1)
{
if (r232==0)
{
printf("aa@");
r232=1;
delay_ms(50);
output_low(pin_e0);
delay_ms(100);
}
}
}