Jump to content

Recommended Posts

#include "PIC16F887.h"

#define XTAL_FREQ 4000000  // config clock to 4mhz.

// Set configuration fuse.


void	setupADC(void);
void	setup(void);
void	setupSPI(void);
char	getADC(void);

void main()



void	setup()	{



void	setupSPI()	{

// Stub


void	setupADC() {

ADCON1	=	0x80; // setting ADC result as right justify, along with Vdd, Vss as reference voltages.
TRISA	=	0x01; // Setting RA0 as an input. (ADC Channel 1?)
ANSEL	=	0x01; // ADC can be used to convert both analog and digital vals. We're specifying that input
				  // is analog.
ADCON0	=	0xC1; // 11000001

char	getADC() {

char	low_val,hi_val,total;
ADCON0	|=	0x02;	  // Started an ADC conversion.
while(ADCON0 & 0x02); // Wait till conversion is complete.

return 0;


Trying to get the ADC working on a PIC16F887.


Errors -



BoostC Optimizing C Compiler Version 6.89 (for PIC16 architecture)


Copyright© 2004-2008 Pavel Baranov

Copyright© 2004-2008 David Hobday


Single user Lite License (Unregistered) for 0 node(s)

Limitations: PIC12,PIC16 max code size:2048 words, max RAM banks:2, Non commercial use only




C:\Users\teja\Desktop\Work\Code\Blink.c(39): error: left operand must be l-value

C:\Users\teja\Desktop\Work\Code\Blink.c(39:9): error: failed to generate expression

C:\Users\teja\Desktop\Work\Code\Blink.c(40): error: left operand must be l-value

C:\Users\teja\Desktop\Work\Code\Blink.c(40:9): error: failed to generate expression

C:\Users\teja\Desktop\Work\Code\Blink.c(41): error: left operand must be l-value

C:\Users\teja\Desktop\Work\Code\Blink.c(41:9): error: failed to generate expression

C:\Users\teja\Desktop\Work\Code\Blink.c(43): error: left operand must be l-value

C:\Users\teja\Desktop\Work\Code\Blink.c(43:9): error: failed to generate expression

C:\Users\teja\Desktop\Work\Code\Blink.c(50): error: left operand must be l-value

C:\Users\teja\Desktop\Work\Code\Blink.c(50:9): error: failed to generate expression



"C:\Program Files\SourceBoost\boostc.pic16.exe" ..\..\..\..\..\Users\teja\Desktop\Work\Code\Blink.c -t PIC16F887

Exit code was 1.

Removing target: Blink.obj


Link to post
Share on other sites
Compiler behaviour is correct. There are problems in your code. I guess you can tell it yourself what's wrong once you check what ADCON1, TRISA, ANSEL etc. are.

I'm sure that tejaswiyvs appreciates your reply. The content of your reply is a tad short on helpfulness.


You could have mentioned that the header files for BoostC follow a long accepted convention where #define constants are always UPPER_CASE though the other popular C compilers for the PIC16F targets define the Special Function Registers with upper case.


You may have gone farther saying that BoostC is more correct in the wider sense it is more trouble for a beginner to PIC and C programming because example source code from other PIC environments will not compile without changing the case of the Special Function Register names.


Just trying to help. :)

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...