PR6(BLuetooth Remote Control)-- c code

Bluetooth, XBee, RF......

PR6(BLuetooth Remote Control)-- c code

Postby cheekangteh » Tue Mar 27, 2012 2:31 pm

hi, i had download the c source code form your website. when i try to build the code in PIC C Compiler..it bring me some error.
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.
cheekangteh
Apprentice
 
Posts: 36
Joined: Mon Dec 26, 2011 5:20 pm

Re: PR6(BLuetooth Remote Control)-- c code

Postby Idris » Tue Mar 27, 2012 3:23 pm

Try change
#include <16f877a.h>
to
#include <pic.h>
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: PR6(BLuetooth Remote Control)-- c code

Postby robosang » Tue Mar 27, 2012 3:41 pm

I think we need to know what is the compiler you are using before giving comments :mrgreen:
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: PR6(BLuetooth Remote Control)-- c code

Postby cheekangteh » Tue Mar 27, 2012 4:08 pm

hi i am using the c compiler. after i change to pic.h, it show me file not found. kindly advice. thanks
cheekangteh
Apprentice
 
Posts: 36
Joined: Mon Dec 26, 2011 5:20 pm

Re: PR6(BLuetooth Remote Control)-- c code

Postby Idris » Tue Mar 27, 2012 4:40 pm

Hi cheekangteh,
I have copy the code and only change #include <16f877a.h> to #include <pic.h>, I got ********** Build successful! **********
Maybe there have a problem on your compiler.
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: PR6(BLuetooth Remote Control)-- c code

Postby cheekangteh » Tue Mar 27, 2012 4:43 pm

hi Idris,

may i know what compiler are you using? thanks
cheekangteh
Apprentice
 
Posts: 36
Joined: Mon Dec 26, 2011 5:20 pm

Re: PR6(BLuetooth Remote Control)-- c code

Postby robosang » Tue Mar 27, 2012 4:49 pm

cheekangteh WROTE:hi i am using the c compiler. after i change to pic.h, it show me file not found. kindly advice. thanks


Brother, we know is C compiler lah.... what particular brand of C compiler? MPLAB C18 C compiler? Hi-TECH C Compiler? CCS C Compiler? MikroC C Compiler? Do I need to be that specific?

cheekangteh WROTE:hi Idris,

may i know what compiler are you using? thanks

I can help Idris to answer this, is C Compiler! :mrgreen:
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: PR6(BLuetooth Remote Control)-- c code

Postby cheekangteh » Tue Mar 27, 2012 4:53 pm

sorry... is ccs c compiler. thanks
cheekangteh
Apprentice
 
Posts: 36
Joined: Mon Dec 26, 2011 5:20 pm

Re: PR6(BLuetooth Remote Control)-- c code

Postby Idris » Tue Mar 27, 2012 4:58 pm

sorry... is ccs c compiler. thanks


Then, you can try MPLAB + Hi Tech C Compiler. It is free and easy. :)
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: PR6(BLuetooth Remote Control)-- c code

Postby robosang » Tue Mar 27, 2012 4:59 pm

Then it is solved. As far as I know, Cytron never use CCS C compiler for their example code. They mostly use Hi-Tech or C18, C30 or C32.

It is not compatible.... we are going no where if we ask you to include pic.h, htc.h or any files in HI-TECH, definately CCS does not have that :mrgreen:

1st, the register name, such as PORTB, bit name, such as RB0 are not same in HItech and CCS. Find out what is the register name use in CCS and replace those registers in the sample code accordingly. Also, find example code compiled using CCS, and try to get the library file. It should have a #include too.

I can only help you until here as I am not familiar with CCS. 8-)
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Next

Return to Wireless Device

Who is online

Users browsing this forum: No registered users and 39 guests

cron