Serial comm between uC and PC...

Status
Not open for further replies.

I thought we were talking about a pic16f877a!! Where is the keyboard? Are you trying to send a message to the pic from a PC? If so what language did you settle on...
 
I thought we were talking about a pic16f877a!! Where is the keyboard? Are you trying to send a message to the pic from a PC? If so what language did you settle on...

OK, once more.....
i am sending data from PC to uC just single letter like 'A' and the uC will receive the data and test it in if cond and then only uC will send
 
I have done some changes in original code for testing but not working now also...

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 to System Engineering Concepts Open loop and closed loop systems, model classification, performance criterion; Validation and testing of models, mathematical modeling " ;

 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     
  }
 
I have done some changes in original code for testing but not working now also...

You have to fall back to the code that was working and modify it step by step. That is the (only) way you can find out where the problem is.
 
You have to fall back to the code that was working and modify it step by step. That is the (only) way you can find out where the problem is

You are not getting me!
i am saying everything is fine but i am not able to know why if cond is not working on pressing any key it work, but it should work/send data when only 'b' is pressed!
 
You are not getting me!
i am saying everything is fine but i am not able to know why if cond is not working on pressing any key it work, but it should work/send data when only 'b' is pressed!

You are not getting me! You have to test all the parts of your system separately. You have to test that the key is working. Test your code step by step.. are the functions working properly etc. be brave and creative.. you can figure it out!
 
You are not getting me! You have to test all the parts of your system separately. You have to test that the key is working. Test your code step by step.. are the functions working properly etc. be brave and creative.. you can figure it out!

Yes key is working on keyboard i have changed to another key and ascii even number is also not working..testing cond is not working
 
Yes key is working on keyboard i have changed to another key and ascii even number is also not working..testing cond is not working

Sound like you need help on debugging. What kind of hardware is that.. point to your previous post if you have already posted a schematic or description. How do you know that the system is not working? What the system should do when it is working?
 
Sound like you need help on debugging. What kind of hardware is that.. point to your previous post if you have already posted a schematic or description. How do you know that the system is not working? What the system should do when it is working?

I have told full story now you are asking what was that.. ??

What kind of hardware is that.. point to your previous post if you have already posted a schematic or description.
everything is same....only i am sending data (single character) from terminal window..
How do you know that the system is not working? What the system should do when it is working?
there is only pic with UART in it, and PC connected with USB module.
at starting when i press any key in keyboard through terminal window it will send to PIC uC and code will test the pressed key and display only when if cond character is matched 'a' like this
 

Sounds good. I can't see any problem there..
 
then why it is not working???
why if cond is not tested and on pressing any key it is working?

If you are confident that your circuit works. Then all you can do is to strip your code down to minimum and start writing it up step-by-step. After each step you test it. When it stops working you have pin-pointed your problem.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…