Problems Compiling 16F887 Tutorial Projects

Programmer, In-Circuit Debugger, PIC Start-Up Kit, Memory Interface...

Problems Compiling 16F887 Tutorial Projects

Postby ddkeo » Thu Jan 12, 2012 6:41 pm

Hi,

Can anyone help me with a compilation error when trying to compile most of the SK40C 16F877 Tutorial Projects.

I am using MPLAB IDE 8.30 and HI-TECH 9.65PL1 compiler and have tried Lite, STD and PRO versions and also 9.60 Lite, STD, and PRO.

Error is [712] C:\.....\Project_4\lcd.c; 276. can't generate code for this expression

I get the same error for PR4, PR5, PR6, PR7, PR9, PR10 & PR15. Only PR2 and PR13 Compile with no errors.

The lcd.c file is the same one as used in all the projects that use an LCD and it compiles fine in PR2 and PR13

Any ideas? or has anyone managed to compile these without any problems?

Please can a member of the Cytron Team confirm which version of MPLAB and Hi-Tech Compiler was used to compile these Projects.

More details about the error message is in my post on the Cytron PIC Microcontroller forum, but from what I have read on the Hi-Tech forum, this error message means that the code statement is too complex for the compiler! So it looks likely to be a compiler error where some versions of the Hi-Tech compiler work ok and others crash with the above error, so I need to find out which one works!

Thanks,
Dave (ddkeo)
ddkeo
Freshie
 
Posts: 6
Joined: Wed Jan 11, 2012 10:54 pm

Re: Problems Compiling 16F887 Tutorial Projects

Postby shahrul » Thu Jan 12, 2012 9:43 pm

That is PIC16F887 or PIC16F877? I don't know because I'm not use the PR. Maybe you screenshot the error.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Problems Compiling 16F887 Tutorial Projects

Postby ABSF » Fri Jan 13, 2012 7:41 am

Is this the PR5 program (line following robot) you're having problems with?

CODE: SELECT_ALL_CODE
#include<pic.h>
__CONFIG(0x3F32);

void main()
{
/*   Sensor:         L            M            R
               RD0            RD1            RD2
   
   Start button=   RB0
   
   Motors:         L                        R
         PWM      RC1                        RC2
               RB5                        RB7
               RB4                        RB6
      
      
*/   unsigned char j;
   TRISB=0b00000001;
   PORTB=0b00000000;
   TRISC=0b00000000;
   PORTC=0b11111111;
   TRISD=0b11111111;
   PORTD=0b00000000;

   

   for (;;)
   {
      if (RB0==0)               //check start button
         break;   
   }
   
   for(;;)
   {
      if (RD1==1)               //check middle sensor
      {
         PORTB=0b10011111;      //move forward
         j=0b10011111;         //save memory
      }
      else if (RD0==1)         //check left sensor
      {
         PORTB=0b10001111;      //move right motor
         j=0b10001111;         //save memory
      }
      else if (RD2==1)         //check right sensor
      {
         PORTB=0b00011111;      //move left motor
         j=0b00011111;         //save memory
      }
      else
      {
         PORTB=j;            //read memory
      }   
   }   
}

         


I have no problem compiling it. There is no sample code for PR4. :shock:

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: Problems Compiling 16F877 Tutorial Projects

Postby ddkeo » Fri Jan 13, 2012 5:46 pm

Hi,

Thanks for your replies.

Sorry for the typo with the heading. The PIC is a 16F877(A).

BTW these projects are The SK40C Tutorial Projects which you can find at:
http://tutorial.cytron.com.my/2011/08/05/sk40c-tutorial/ and not the Project DIY ones shown on the Cytron web site. Sorry for any confusion!

Anyway after many hours for of testing with just about all the recent versions of the Hi-Tech compilers and MPLAB I have now managed to compile all but PR5.

For anyone who is interested in trying out these Tutorial Projects of which there are 15 in all, you will find that all bar PR5 will compile with the Hi-Tech version 9.70 in LITE Mode and MPLAB V8.70. They will NOT compile with any other version of the Hi-Tech compiler from 9.60 to 9.83 with the exception of PR1, PR2 and PR13 which will probably work with anything including V9.65.

Hopefully someone at Cytron will now add this information to the Tutorial website and save people a lot of hassle when trying to compile the programs. Maybe they could also advise which compiler and version of MPLAB they used to compile PR5 as I still have had no luck with this one!

Best of luck with your projects,
Dave (ddkeo)
ddkeo
Freshie
 
Posts: 6
Joined: Wed Jan 11, 2012 10:54 pm

Re: Problems Compiling 16F877 Tutorial Projects

Postby shahrul » Fri Jan 13, 2012 6:12 pm

ddkeo WROTE:Hi,
For anyone who is interested in trying out these Tutorial Projects of which there are 15 in all, you will find that all bar PR5 will compile with the Hi-Tech version 9.70 in LITE Mode and MPLAB V8.70. They will NOT compile with any other version of the Hi-Tech compiler from 9.60 to 9.83 with the exception of PR1, PR2 and PR13 which will probably work with anything including V9.65.

I don't understand why the code only can compile with v9.70 only, but cannot on older or newer.
As my experience, the is some different declaration from older to newer. Now I'm using Hi-Tech v9.83 (latest)
Ex, older version (I don't remember what version and below) use ADGO or GODONE, then newer version use GO.
For I2C, last use RW then now use R_W.

All the declaration, you search in file pic.h then find the file corresponding to which PIC type.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Problems Compiling 16F887 Tutorial Projects

Postby ddkeo » Fri Jan 13, 2012 6:38 pm

Hi sharul,

Please see my last post on the PIC Microcontrollers index for the reason and explanation from Hi-Tech.!!

Thanks,
Dave (ddkeo)
ddkeo
Freshie
 
Posts: 6
Joined: Wed Jan 11, 2012 10:54 pm


Return to PIC Development Tool

Who is online

Users browsing this forum: No registered users and 14 guests