Serial comm using pic16f877a....

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
I have downloaded and installed for my window 7 this one
PL2303_Prolific_DriverInstaller_windows_all is this fine???
now what to do?
 

t06afre

Joined May 11, 2009
5,934
Then you must download a terminal program. This work with Windows 7 and is free. http://sourceforge.net/projects/realterm/ Then set the serial port settings on terminal program to match your settings on the PIC. Those settings are under port banner in the latter terminal program. Some use of google to get the basics on using the serial port is also recommended. You have to start focusing on details. Not just walk around as a sleepwalker expecting that we will help you then you have taken a wrong turn.
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Then you must download a terminal program. This work with Windows 7 and is free. http://sourceforge.net/projects/realterm/ Then set the serial port settings on terminal program to match your settings on the PIC. Those settings are under port banner in the latter terminal program. Some use of google to get the basics on using the serial port is also recommended. You have to start focusing on details. Not just walk around as a sleepwalker expecting that we will help you then you have taken a wrong turn.

Yes, i have installed what setting is to be done??
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Hi
I am using this code showing error...

Rich (BB code):
#include <htc.h>
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000
#define NINE 0     /* Use 9bit communication? FALSE=8bit */

#define BAUD 9600  

    #define RX_PIN TRISB2
    #define TX_PIN TRISB5
#define DIVIDER ((int)(_XTAL_FREQ/(16UL * BAUD) -1))
#if NINE == 1
#define NINE_BITS 0x40
#else
#define NINE_BITS 0
#endif
#if HIGH_SPEED == 1
#define SPEED 0x4
#else
#define SPEED 0
#endif
 Initialize ();







void main ()
{
    Initialize ()
{   
    while(1)
    {
        putchar('H');   //print the letter 'H'
        putchar('i');   //print 'i'
        putchar('\r');  // return to beginning of line
        putchar('\n');  //new line
    }
}    
}



Initialize ()
{
    RX_PIN = 1;    
    TX_PIN = 1;          
    SPBRG = DIVIDER;         
    RCSTA = (NINE_BITS|0x90);
    TXSTA = (SPEED|NINE_BITS|0x20);
}


Make: The target "C:\Users\Abc\Documents\mplab\UART.p1" is out of date.
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe" --pass1 C:\Users\Abc\Documents\mplab\UART.c -q --chip=16F877A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [312] C:\Users\Abc\Documents\mplab\UART.c; 32.1 ";" expected
Warning [361] C:\Users\Abc\Documents\mplab\UART.c; 36.1 function declared implicit int
Error [285] C:\Users\Abc\Documents\mplab\UART.c; 40.1 no identifier in declaration
Warning [374] C:\Users\Abc\Documents\mplab\UART.c; 40.1 missing basic type; int assumed
Error [314] C:\Users\Abc\Documents\mplab\UART.c; 40.1 ";" expected
Error [285] C:\Users\Abc\Documents\mplab\UART.c; 41.1 no identifier in declaration
Warning [374] C:\Users\Abc\Documents\mplab\UART.c; 41.1 missing basic type; int assumed
Error [314] C:\Users\Abc\Documents\mplab\UART.c; 41.1 ";" expected

********** Build failed! **********
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
after that...
Error [1098] C:\Program Files (x86)\HI-TECH Software\PICC\9.83\sources\putchar.c; 16. conflicting declarations for variable "_putchar" (C:\Users\Abc\Documents\mplab\UART.c:35)

********** Build failed! **********
 

tshuck

Joined Oct 18, 2012
3,534
This can't be your whole code, where is UART.c? That is where the problem is. Read the error description, there are multiple declarations for putchar...
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
After renaming file there is error..........


Make: The target "C:\Users\Abc\Documents\mplab\main.p1" is out of date.
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe" --pass1 C:\Users\Abc\Documents\mplab\main.c -q --chip=16F877A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Warning [361] C:\Users\Abc\Documents\mplab\main.c; 35.1 function declared implicit int
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe" -omain.c.cof -mmain.c.map --summary=default --output=default main.p1 --chip=16F877A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode) V9.83
Copyright (C) 2011 Microchip Technology Inc.
(1273) Omniscient Code Generation not available in Lite mode (warning)
Error [1098] C:\Program Files (x86)\HI-TECH Software\PICC\9.83\sources\putchar.c; 16. conflicting declarations for variable "_putchar" (C:\Users\Abc\Documents\mplab\main.c:35)

********** Build failed! **********
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
After changing few more things there are still error........

Rich (BB code):
#include <htc.h> 
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
 #define _XTAL_FREQ 20000000
 #define NINE 0     /* Use 9bit communication? FALSE=8bit */  
 #define BAUD 9600        
 #define RX_PIN TRISB2   
  #define TX_PIN TRISB5
 #define DIVIDER ((int)(_XTAL_FREQ/(16UL * BAUD) -1))
 #if NINE == 1
 #define NINE_BITS 0x40
 #else #define NINE_BITS 0 
#endif 
#if HIGH_SPEED == 1
 #define SPEED 0x4
 #else #define SPEED 0 
#endif void Initialize (void);  <----- YOU FORGOT THE "void's"  
       void main () {     Initialize ();  <---- YOU FORGOT THE";" {     
   while(1)     {    
     putchar('H');   //print the letter 'H'    
     putchar('i');   //print 'i' 
        putchar('\r');  // return to beginning of line   
      putchar('\n');  //new line     } }   
  }       void Initialize ()  <----- YOU FORGOT THE "void" 
{     RX_PIN = 1;        
 TX_PIN = 1;       
        SPBRG = DIVIDER;              RCSTA = (NINE_BITS|0x90);     TXSTA = (SPEED|NINE_BITS|0x20); }
 

tshuck

Joined Oct 18, 2012
3,534
After changing few more things there are still error........
That doesn't really tell me much, now does it?

Anyway, your program is simple enough at this point that it isn't too bad, but that will not be the case for bigger programs...

You should learn how to layout your code better. One thing that helps is to not put the opening curly bracket on the same line. Keep a consistent indentation, that helps you see what goes where.

Next, preprocessor directives are line-by-line interpreted, so you can't combine two commands on a single line, you can, however extend a command to multiple lines by adding '\' to the end of the command line, but that is neither here, nor there...

Here's your program spruced up a little bit, notice the easy readability?
Rich (BB code):
#include <htc.h> 
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);

 #define _XTAL_FREQ 20000000
 #define NINE 0     /* Use 9bit communication? FALSE=8bit */  
 #define BAUD 9600        
 #define RX_PIN TRISB2   
 #define TX_PIN TRISB5
 #define DIVIDER ((int)(_XTAL_FREQ/(16UL * BAUD) -1))
 #if NINE == 1
    #define NINE_BITS 0x40
 #else
    #define NINE_BITS 0 
#endif 
#if HIGH_SPEED == 1
    #define SPEED 0x4
    #else #define SPEED 0 
#endif 

void Initialize (void);  //<----- YOU FORGOT THE "void's"  


void main ()
{     
    Initialize ();  <---- YOU FORGOT THE";" {     
    while(1)
    {    
     putchar('H');   //print the letter 'H'    
     putchar('i');   //print 'i' 
     putchar('\r');  // return to beginning of line   
     putchar('\n');  //new line     
    }       
}    

void Initialize ()  //<----- YOU FORGOT THE "void"
{
    RX_PIN = 1;        
    TX_PIN = 1;       
    SPBRG = DIVIDER;
    RCSTA = (NINE_BITS|0x90);
    TXSTA = (SPEED|NINE_BITS|0x20);
}
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Not working showing error..........
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe" --pass1 C:\Users\Abc\Documents\mplab\main.c -q --chip=16F877A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Warning [361] C:\Users\Abc\Documents\mplab\main.c; 29.1 function declared implicit int
Error [314] C:\Users\Abc\Documents\mplab\main.c; 37.1 ";" expected
Error [192] C:\Users\Abc\Documents\mplab\main.c; 42.10 undefined identifier "SPEED"
 

tshuck

Joined Oct 18, 2012
3,534
Perhaps I should have been more thorough in checking your code... :rolleyes:
Not working showing error..........
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.83\bin\picc.exe" --pass1 C:\Users\Abc\Documents\mplab\main.c -q --chip=16F877A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Warning [361] C:\Users\Abc\Documents\mplab\main.c; 29.1 function declared implicit int
Error [314] C:\Users\Abc\Documents\mplab\main.c; 37.1 ";" expected
Error [192] C:\Users\Abc\Documents\mplab\main.c; 42.10 undefined identifier "SPEED"
....sounds reasonable, "SPEED" is never defined, it is only defined,
#if HIGH_SPEED == 1
, since it isn't, "SPEED" is never assigned...

Also, you are making both TX and RX inputs with:
RX_PIN = 1;
TX_PIN = 1;
 
Top