UART problem in P16F877A

tshuck

Joined Oct 18, 2012
3,534
...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).
 

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
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

Its easy..
u can use this code with modification...
Rich (BB code):
 #include <pic.h>              // pic specific identifiers 
 #define _XTAL_FREQ  20000000        // Xtal speed 
  __CONFIG(0x3F72);                // Config bits   
            unsigned char ch; 
unsigned char f;
 unsigned char  HSerin(void);  
void HSerinit(void);  
void HSerout(unsigned char f);
 unsigned char *a= "  Introduction  " ; 
  void main(void)                        // program entry  
    {        
 int index = 0;  
    ADCON1 = 0x6;                    // Analogue off   
     HSerinit();        
 __delay_ms(150);  
    while(1)                        // endless Loop   
       {   
 HSerin();  
if(RCREG=='b'); 
{  f =  'a' ;  
    HSerout(f);
 __delay_ms(250); 
        }    
    }  
 }        
   void HSerinit()      {   
      TRISC = 0b10000000;                    // should ideally be set      
SPBRG = 129;                    // 20Mhz xtal 9600 BAUD     
   TXSTA = 0x24;                    // TXEN and BRGH   
    RCSTA = 0x90;                    // SPEN and CREN  
    }   
  void HSerout(unsigned char f)   
  {      while(!TXIF);                   // Wait for module to finish    
  TXREG = f;                        // ready to send  
    }  
 unsigned char HSerin()      {    
 while(!RCIF);                   // Wait for a character   
   return RCREG;                    // return character     
   }
 
Top