Discussion in "Project Help" started by    mhmd_saud    Nov 11, 2009.
Sun Apr 04 2010, 04:27 pm
just place the .h file in that software library directory where other header files are.

and then include this line at the top.

#include <16F877A.h>

hope you problem solve.
Sun Apr 04 2010, 05:34 pm
I've placed the file in every possible folder in the Mikroelctonika directory, but it still says the include file can't be opened. Could there be something wrong with the file?
Mon Apr 05 2010, 11:47 am
I tried copying whatever's written in the 16f877a.h file and pasted it before the codes, and errors still came out at this part of the file :

volatile char indf @INDF;
volatile char tmr0 @TMR0;
volatile char pcl @PCL;
volatile char status @STATUS;
volatile char fsr @FSR;
volatile char porta @PORTA;
volatile char portb @PORTB;
volatile char portc @PORTC;
volatile char portd @PORTD;
volatile char porte @PORTE;
volatile char pclath @PCLATH;
volatile char intcon @INTCON;
volatile char pir1 @PIR1;
volatile char pir2 @PIR2;
volatile char tmr1l @TMR1L;
volatile char tmr1h @TMR1H;
volatile char t1con @T1CON;
volatile char tmr2 @TMR2;
volatile char t2con @T2CON;
volatile char sspbuf @SSPBUF;
volatile char sspcon @SSPCON;
volatile char ccpr1l @CCPR1L;
volatile char ccpr1h @CCPR1H;
volatile char ccp1con @CCP1CON;
volatile char rcsta @RCSTA;
volatile char txreg @TXREG;
volatile char rcreg @RCREG;
volatile char ccpr2l @CCPR2L;
volatile char ccpr2h @CCPR2H;
volatile char ccp2con @CCP2CON;
volatile char adresh @ADRESH;
volatile char adcon0 @ADCON0;
volatile char option_reg @OPTION_REG;
volatile char trisa @TRISA;
volatile char trisb @TRISB;
volatile char trisc @TRISC;
volatile char trisd @TRISD;
volatile char trise @TRISE;
volatile char pie1 @PIE1;
volatile char pie2 @PIE2;
volatile char pcon @PCON;
volatile char sspcon2 @SSPCON2;
volatile char pr2 @PR2;
volatile char sspadd @SSPADD;
volatile char sspstat @SSPSTAT;
volatile char txsta @TXSTA;
volatile char spbrg @SPBRG;
volatile char cmcon @CMCON;
volatile char cvrcon @CVRCON;
volatile char adresl @ADRESL;
volatile char adcon1 @ADCON1;
volatile char eedata @EEDATA;
volatile char eeadr @EEADR;
volatile char eedath @EEDATH;
volatile char eeadrh @EEADRH;
volatile char eecon1 @EECON1;
volatile char eecon2 @EECON2;

So what happens if I just erase that part and use the rest?
Tue Apr 06 2010, 12:14 am
Okay.. multiple errors here


and I keep getting error for undeclared ANSEL, ANSELH, etc.
I was told that I have to include a header file before the codes. I have no idea what's the header file, or where I can get it. I've tried googling and all. I'm lost.


The 16f877 does not actually have an ANSEL or ANSELH, so remove those lines
or change to suit the equivalent registers in the 16f877.

The header info is added to your project by Microc when you
select your device, so #include <16F877A.h> is not needed.

If you ever need to add a header file, put the .h file in the same folder as your .mccpi file
and use
#include "16F877A.h" (substitute filename) . . . use " not < for this setup.

Finally... the file I posted was PIC16F877A.h not 16F877A.h
sorry about the confusion.

Your sample program was not written for your chip, so you should deleted it and
look for examples for the 16F877A.

Try this

char uart_rd;

void main()
 {

UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize

UART1_Write_Text("AT");
UART1_Write(10);
UART1_Write(13);


while (1)
{ // Endless loop
 if (UART1_Data_Ready())
 { // If data is received,
  uart_rd = UART1_Read(); // read the received data,
  UART1_Write(uart_rd); // and send data via UART
}  //end if data ready
} //end while

} //end main



Create a new project for this code.
Be sure to select the 16F877A as pic type and set the crystal speed as the one you will
be using.
From the Microc top bar select "View"
Select "Library manager"
Tick the "Uart" box at the bottom.




[ Edited Fri Apr 09 2010, 11:43 pm ]
Tue Apr 06 2010, 12:29 pm
I've tried searching for the sample for 16f877a, and didn't find anything except for confusing forums.

My time is so limited right now, I have no idea what to do.
Wed Apr 07 2010, 06:24 am


My time is so limited right now, I have no idea what to do.

VioletRock


Do what I said in my last post.
Create a new project using the code I posted.

Don't add any other header etc.. it should compile with no errors.
Then try it programming your PIC and attaching to Hyperterminal,or running a simulation.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am