UART problem in P16F877A

Discussion in 'Embedded Systems and Microcontrollers' started by ahmedabosriaa, Jul 2, 2013.

  1. ahmedabosriaa

    Thread Starter New Member

    Jul 2, 2013
    2
    0
    Hi guys :)

    I have a problem in this code.

    Simply am trying to let the Port.RB1 high when the received data = 123 & low if the it 321

    Hope to find some help here :)

    Here is the like for the files for the simulation & code
    Sorry i can't upload it:
    http://www.4shared.com/rar/1UBPGI4W/P16F877A.html
     
  2. Dawud Beale

    Member

    Feb 10, 2012
    275
    7
    can you copy and paste in your code
     
  3. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    ...the forum also accepts .zip, so you could zip your files in a folder to upload here, but the preferred method it's to just paste the code here (using code tags-looks like "#" when editing your post).
     
  4. absf

    Senior Member

    Dec 29, 2010
    1,490
    371
    Unable to open or download........

    Asking for cell phone number.....:confused:
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Here is the project files from the OP in a zip. It looks like it is a Proteus project.
     
  6. RRITESH KAKKAR

    Senior Member

    Jun 29, 2010
    2,831
    89

    Its easy..
    u can use this code with modification...
    Code ( (Unknown Language)):
    1.  
    2.  
    3.  #include <pic.h>              // pic specific identifiers
    4.  #define _XTAL_FREQ  20000000        // Xtal speed
    5.   __CONFIG(0x3F72);                // Config bits  
    6.             unsigned char ch;
    7. unsigned char f;
    8.  unsigned char  HSerin(void);  
    9. void HSerinit(void);  
    10. void HSerout(unsigned char f);
    11.  unsigned char *a= "  Introduction  " ;
    12.   void main(void)                        // program entry  
    13.     {        
    14.  int index = 0;  
    15.     ADCON1 = 0x6;                    // Analogue off  
    16.      HSerinit();        
    17.  __delay_ms(150);  
    18.     while(1)                        // endless Loop  
    19.        {  
    20.  HSerin();  
    21. if(RCREG=='b');
    22. {  f =  'a' ;  
    23.     HSerout(f);
    24.  __delay_ms(250);
    25.         }    
    26.     }  
    27.  }        
    28.    void HSerinit()      {  
    29.       TRISC = 0b10000000;                    // should ideally be set      
    30. SPBRG = 129;                    // 20Mhz xtal 9600 BAUD    
    31.    TXSTA = 0x24;                    // TXEN and BRGH  
    32.     RCSTA = 0x90;                    // SPEN and CREN  
    33.     }  
    34.   void HSerout(unsigned char f)  
    35.   {      while(!TXIF);                   // Wait for module to finish    
    36.   TXREG = f;                        // ready to send  
    37.     }  
    38.  unsigned char HSerin()      {    
    39.  while(!RCIF);                   // Wait for a character  
    40.    return RCREG;                    // return character    
    41.    }
     
Loading...