View Single Post
Old 13-06-2008, 09:57 AM   #34
bean984
Đệ tử 3 túi
 
Tham gia ngày: Dec 2007
Bài gửi: 51
:
còn đây là code con slave:
Code:
////////////////////////////////////////////////////////////*/
//ham nhan ky tu
#INT_RDA
void RECEIVER()
{
   int x,y;
   chuoi[x]=fgetc(PC);
   if (chuoi[x]=='@')
      {
         chuoi[x]=null;
         dodaichuoi=strlen(chuoi);
         if (chuoi[0]=='a')
            {
            count0=count0+1;//dem so lan nhan đc
            r232=1;//set co nhan
            }
         x=0;
      }
   else x=x+1;
}
//////////////////////////////////////////////////////////
void main(void)
{
   int luudiemcat;
   set_tris_a(255); 
   set_tris_b(255);
   set_tris_d(0);
   set_tris_e(0); 
   portb=porte=0;
   output_low(pin_E0);
   portd=0;
   r232=0;
   enable_interrupts(global);
   enable_interrupts(int_RDA);
   setup_adc(adc_clock_internal);

   while(true)
   {
      if (r232==1)
         {
               output_high(pin_e0);
               delay_ms(50);
               printf("bb@");
               delay_ms(200);
               output_low(pin_e0);
               r232=0;
               lcd_display_str(0,0,chuoi);
               lcd_display_int8(0,5,dodaichuoi);
               lcd_display_int16(0,10,count0,0);
         }
   }
}
bean984 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn