i am using 16f877a, so for the include part, i just using
#include <16f877a.h>
below are the code:
- CODE: SELECT_ALL_CODE
//=============================================================================================
//
// Author :Cytron Technologies
// Project :DIY Project
// Project description :PR6-Bluetooth Remote Control
// Date :21 May 2009
//
//=============================================================================================
//=============================================================================================
// Include file
//=============================================================================================
#include <16f877a.h>
//=============================================================================================
// Configuration
//=============================================================================================
__CONFIG(0x3F32);
//=============================================================================================
//Define
//=============================================================================================
#define seg PORTD // define 7 segment as PORTD
//==============================================================================================
// Function Prototype
// User can write all the necessary function here
//==============================================================================================
unsigned char a;
void init(void) // subroutine to initialize
{
SPBRG=0x0A; // set baud rate as 115200 baud
BRGH=1;
TXEN=1;
CREN=1;
SPEN=1;
TRISD = 0b00000000;
seg = 0b00000000;
}
void display(unsigned char c) // subrountine to display the text on the screen
{
while (TXIF == 0);
TXREG = c;
}
unsigned char receive(void) // subrountine to receive text from PC
{
while (RCIF == 0);
a = RCREG;
return a;
}
//================================================================================================
// Main Function
// This is the main function where program start to execute
//================================================================================================
void main(void)
{
init();
while(1) // Wait for 'ok' to be entered by user
{
a = receive();
if (a == 'o')
{
a = receive();
if (a == 'k') break;
}
}
display('C'); // Text will display on Hyperterminal after 'ok' is entered
display('y');
display('t');
display('r');
display('o');
display('n');
display(0x0a); //Go to new line
display(0x0d);
display('P');
display('r');
display('e');
display('s');
display('s');
display(0x20); // Space
display('a');
display('n');
display('y');
display(0x20); // Space
display('n');
display('u');
display('m');
display('b');
display('e');
display('r');
seg = 1;
// wait for number and display it on 7 segment
// The number display on 7 segment is depends on what number entered in Hyperterminal.
while(1)
{
a = receive();
if (a=='1'||a=='2'||a=='3'||a=='4'||a=='5'||a=='6'||a=='7'||a=='8'||a=='9'||a=='0')
{
seg = a-0x30;
}
}
}
error:
***Error28 "PR6(Bluetooth Remote Control).c" Line 20 (10,16): Expecting identifier
*** Error 43 "PR6(Bluetooth Remote Control).c" Line 20 (17,18): Expecting a declaration.
***Error12 "PR6(Bluetooth Remote Control).c" Line 38 (4,9): Undefined identifier SPBRG
*** Error 12 "PR6(Bluetooth Remote Control).c" Line 39 (4,8): Undefined identifier BRGH
***Error12 "PR6(Bluetooth Remote Control).c" Line 40 (4,8): Undefined identifier TXEN
*** Error 12 "PR6(Bluetooth Remote Control).c" Line 41 (4,8): Undefined identifier CREN
*** Error 12 "PR6(Bluetooth Remote Control).c" Line 42 (4,8): Undefined identifier SPEN
*** Error 12 "PR6(Bluetooth Remote Control).c" Line 43 (10,15): Undefined identifierTRISD
*** Error 12 "PR6(Bluetooth Remote Control).c" Line 44 (10,11): Undefined identifier PORD D
***Error12 "PR6(Bluetooth Remote Control).c" Line 49 (16,20): Undefined identifier TXIF
***Error12 "PR6(Bluetooth Remote Control).c" Line 50 (10,15): Undefined identifier TXREG
***Error12 "PR6(Bluetooth Remote Control).c" Line 55 (16,20): Undefined identifier RCIF
***Error12 "PR6(Bluetooth Remote Control).c" Line 56 (8,13): Undefined identifier RCREG
*** Error 12 "PR6(Bluetooth Remote Control).c" Line 105 (11,12):Undefined identifier PORD D
*** Error 12 "PR6(Bluetooth Remote Control).c" Line 114 (17,18):Undefined identifier PORD D
kindly advice how can i solve for this error? i had try to define the thing with code below
- CODE: SELECT_ALL_CODE
#define BRGH TXSTAbits.BRGH
#define TXEN TXSTAbits.TXEN
#define CREN RCSTAbits.CREN
#define SPEN RCSTAbits.SPEN
#define TXIF PIR1bits.TXIF
#define RCIF PIR1bits.RCIF
#define TX9 TXSTAbits.TX9
#define SYNC TXSTAbits.SYNC
i this bring me to more error.