Serial comm using pic16f877a....

NO, zero pcb ......
its not working now it is not giving power also, don't know why??
i have extra chip also but no SMD iron type to solder it!
When you plug in the module, is it detected by the system?

Plus, I saw your same thread elsewhere in the Electro-Tech Online forums. Keep it at one same place.
 

DerStrom8

Joined Feb 20, 2011
2,390
Plus, I saw your same thread elsewhere in the Electro-Tech Online forums. Keep it at one same place.
Posting on two different forums isn't the problem. The problem is when you take work given to you on one, and post it as your own on the other. That is a form of plagiarism, of which Ritesh has been guilty on MANY occasions.

This is why most people have stopped helping him. He's stealing the work from other people and is doing nothing on his own. Then he submits the work to his professors claiming he did it, when in reality it is the work of dozens of people online and he hasn't helped at all.
 
Posting on two different forums isn't the problem. The problem is when you take work given to you on one, and post it as your own on the other. That is a form of plagiarism, of which Ritesh has been guilty on MANY occasions.

This is why most people have stopped helping him. He's stealing the work from other people and is doing nothing on his own. Then he submits the work to his professors claiming he did it, when in reality it is the work of dozens of people online and he hasn't helped at all.
The thread OP had certainly one problem too which I should point out - he has no (or limited) exposure on C/C++. Like you said, he probably cut and pasted this somewhere and (probably) refuse to analyze the code. He should have a starter one or two semesters in basic programming courses, and if he had, he should be already writing his version of this code already.

Programming is not where it's learned in just a mere few hours. It should be learned with passion and with full curiousity.
 

DerStrom8

Joined Feb 20, 2011
2,390
The thread OP had certainly one problem too which I should point out - he has no (or limited) exposure on C/C++. Like you said, he probably cut and pasted this somewhere and (probably) refuse to analyze the code. He should have a starter one or two semesters in basic programming courses, and if he had, he should be already writing his version of this code already.

Programming is not where it's learned in just a mere few hours. It should be learned with passion and with full curiousity.
100% agreed. Once again though, that's the problem--he takes other peoples' code and posts it as his own, and refuses to learn it himself. That's why a lot of people have stopped trying to help him.


Ritesh, when you read this I want you to know--I'm not trying to be rude, I want you to wake up and see what's happening here. I'm trying to help you. If you keep doing it the way you are now, you will never learn anything, and you will be unable to pass your classes at the university and you will fail at a job later in life. It's time you start back at the basics and LEARN this stuff yourself. Otherwise you will get nowhere. You may think you can just ask us for help and get all the answers you need, and you probably think you can just keep doing that for the rest of your life. But that's wrong. One day we will not be here to help you. Same with people on other forums (I know you're a member on several, not just AAC and ETO). That time is coming soon that nobody will want to help you. You MUST start learning this ON YOUR OWN. If you don't, you're setting yourself up for failure.
 
100% agreed. Once again though, that's the problem--he takes other peoples' code and posts it as his own, and refuses to learn it himself. That's why a lot of people have stopped trying to help him.


Ritesh, when you read this I want you to know--I'm not trying to be rude, I want you to wake up and see what's happening here. I'm trying to help you. If you keep doing it the way you are now, you will never learn anything, and you will be unable to pass your classes at the university and you will fail at a job later in life. It's time you start back at the basics and LEARN this stuff yourself. Otherwise you will get nowhere. You may think you can just ask us for help and get all the answers you need, and you probably think you can just keep doing that for the rest of your life. But that's wrong. One day we will not be here to help you. Same with people on other forums (I know you're a member on several, not just AAC and ETO). That time is coming soon that nobody will want to help you. You MUST start learning this ON YOUR OWN. If you don't, you're setting yourself up for failure.
Actually, a minor/small prerequisite for microcontroller subjects is at least with a semester of digital electronics. No kidding - in my workplace/university, students NEED to pass digital electronics before they have to take Microcontroller Systems subject. No pass or no take equals to no Microcontroller subject.

To be honest, I'm not from the Electric/Electronic Engineering school. I have only five to seven semesters of electronic/electric related subjects, and most of them I picked it up myself. How I picked it up? During the short semester holidays I read up a lot of books (and datasheets), and keep experimenting.

I would ask that guy whether he is already exposed to Digital Electronics before.

My suggestion to Ritesh is get a small and cheap microcontroller training board (usually with a PIC16F877A or bring one's own). It has the regulators, probably a UART->USB converter, some LEDs and with the ICSP port with it. At least he won't have to fumble at shaky connections, wrong voltages and so on.
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
OK, The problem was not module the USB cable was having some problem i was thinking that i have lost usb module ....

anyway, i have figure out the main cause of problem it was wrong parameter mention on usb module as i said when i short both terminal it work after that i have removed the rx wire from uC and changed tx to tx pin of usb module then it work fine there is no error..............
 

tshuck

Joined Oct 18, 2012
3,534
OK, The problem was not module the USB cable was having some problem i was thinking that i have lost usb module ....

anyway, i have figure out the main cause of problem it was wrong parameter mention on usb module as i said when i short both terminal it work after that i have removed the rx wire from uC and changed tx to tx pin of usb module then it work fine there is no error..............
So, what was the problem?
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Hi,

I am working more on UART passing string and not suck with if cond to do a task......
the problem is that when any key is press it work not follow the cond , why??

Rich (BB code):
if(ch=='a'); 
{  
 f =  'a' ;    
  HSerout(f); 
__delay_ms(250);
 

tshuck

Joined Oct 18, 2012
3,534
A string is an array of chars , which are you testing in the code snippet?

Are you using interrupts for reception, or is this still polling?

Posting the whole code would help you get answers, as per usual. The snippet looks fine...
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
I have done some changes in original code for testing but not working now also...
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 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     
  }
 

DerStrom8

Joined Feb 20, 2011
2,390
Why do you have "void HSerinit(void)" ? You create the prototype later on. The way you have it now, it won't know which one to run. Remove the first "void HSerinit(void)" line and try again.

Either that or explain to me what you think it's doing there right now.
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Why do you have "void HSerinit(void)" ? You create the prototype later on. The way you have it now, it won't know which one to run. Remove the first "void HSerinit(void)" line and try again.
I don't that might be the problem it used to initialize the UART..
 

DerStrom8

Joined Feb 20, 2011
2,390
It could definitely be a problem. Your program calls HSerinit(), but you have it declared twice--one with the initialization code and one without. The program won't know which one to call, so either it skips it (unlikely) or it calls the first one it sees--the empty one.

That is assuming I remember prototype declaration code correctly. Been a while since I've used a uC, most of my programming lately has been on the computer. But try commenting out the line that says "void HSerinit(void);" (NOT the prototype). See if it helps.
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
It could definitely be a problem. Your program calls HSerinit(), but you have it declared twice--one with the initialization code and one without.
where???
Rich (BB code):
__CONFIG(0x3F72);                // Config bits     
          unsigned char ch; 
unsigned char f; 
unsigned char  HSerin(void); 
 void HSerinit(void); 
 void HSerout(unsigned char f);
 

DerStrom8

Joined Feb 20, 2011
2,390
First of all, I wish you would fix the spacing in your code. Use Tab to put code within code blocks. It makes things much cleaner and easier to read.

Anyway, look at the bold statements (I can't do bold in the code tags, so this is going to lose all its spacing):

#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 believe the first bold statement is unnecessary, but someone will have to verify that.
 

tshuck

Joined Oct 18, 2012
3,534
The function prototype should not be omitted. Compilers are known to do pretty sketchy things when there is no prototype, best case, it assumes an int return type. Omitting it will probably cause a warning for the PIC compiler...

This should be left in.
 
Top