Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Serial comm between uC and PC...

Status
Not open for further replies.
[MODNOTE]Deleted Off Topic[/MODNOTE]
 
Last edited by a moderator:
OK, I am trying to make condition based transmission from let say if 'A' is pressed in keyboard it wil show "jhdghgk" and if 'B' is pressed it should show "kjyhjkdqwefjgtjk" like this....
but the problem is that when i do this on pressing any of key it work but it should match the key to condition then it should show the result this is what i am asking...

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
 
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 am so glad you finally got it working.. good job!
 
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.. :confused:??

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
 
I have told full story now you are asking what was that.. :confused:??


everything is same....only i am sending data (single character) from terminal window..

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.
 
Are you asking or telling me?
 
I have done some changes in original code for testing but not working now also...

Code:
if(RCREG=='b');

Your problem is on this line. It is a very basic problem, so you will find it very easily.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top