PDA

View Full Version : Pic16F877 failure to assemble



Old Man Emu
- 20th June 2008, 10:48
G'Day..
I am copying Chuck Hellebuyck's Pic16F876 A/D for a 5 LED idication on a variable Pot.
V+ in = progressive LEDS out. I have included files "16F877.Bas" and "pbppic14.lib"
I get back 21 compilation errors for ' bad expression pbppic14lib.'I have checked both files for comparisons to the errors and can find no reference to any syntax expressions therein.
The compilers first error is ' TrisB = %00000000. Am I missing something......Thanks

mackrackit
- 20th June 2008, 10:55
Who is Chuck and what does his code look like?
Please post your code so we can tell what is going on.

Neither one of those files you mentioned should be included in your code. PIC Basic takes care of that.

Old Man Emu
- 20th June 2008, 10:58
' RA2 Pot connection
' RB4 LED4
' RB3 LED3
' RB2 LED2
' RB1 LED1
' RB0 LED0
'-------------------- Revision History ----------------------------------------
include "pbppic14.lib"
include "16F877.bas"
'-------------------- Constants and Defines -----------------------------------

'Define ACDIN parameters

Define ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source ( 3 = RC )
DEFINE ADC_SAMPLEUS 50 ' Set sampling time to micro-seconds

'-------------------- Variables -----------------------------------------------

adval var byte ' Create adval to store result



PortB = %00000000 ' All outputs off to start
TrisB = %00000000 ' All of PortB is Outputs

MAIN:

TRISA = %00111111 ' Set PortA to all Inputs
ADCON1 = %00000010 ' Set PortA Analogue

LOOP:

ADCIN 2, adval ' Read channel to Adval

'******************* Let's Drive some LEDS ************************************

Ledtst1:
if adval > 25 tHEN tst2 ' If A/D val is less than 25 then

PortB = %0000001 ' light LED0 only
goto cont ' Continue with Programme
tst2:
if adval > 75 then tst3 ' If A/D val is between 25 - 75

PortB = %00000011 ' light LED0 - LED1 only
goto cont ' Continue with Programme
tst3:
if adval > 125 then tst4 ' If A/D val is between 75 - 125

PortB = %00000111 ' light LED0 - LED2 only
Goto cont ' Continue with Programme
tst4:
if adval = 175 then tst5 ' If A/D val is between 125 - 175

PortB = %00001111 ' light LED0 - LED3 only
goto cont ' Continue with Programme
tst5:
PortB = %00011111 ' If A/D value is greater than 175
' Then light all LEDS0 - 4
cont:
Pause 100 ' wiat 1 second
goto LOOP ' Go back to LOOP

end

mackrackit
- 20th June 2008, 11:07
I commented out these two lines


include "pbppic14.lib"
include "16F877.bas"

and the rest of your code compiled here. Give it a try. I will look at the remainder in a bit.

Old Man Emu
- 20th June 2008, 11:20
I originally included the two files because without them the compilation errors are...
'Macro label?L not found in macro file' , 'Macro ADCIN?CN not found in macro file', etc. for all the commands used in this programme..I am beginning to think that my last update of MicroCodePlus Studio may be crappy, although it compiles 16F84A's OK.I may have to look at reinstalling this programme ...Thanks ..Rod.

mackrackit
- 20th June 2008, 11:25
Do you have MCS set up to us MPASM? Should not make a difference with you PIC though.

The machine I tested your code on does not have MCS. I used MPLAB.

What version of PIC BASIC PRO and MCS do you have?

Old Man Emu
- 20th June 2008, 11:39
I am only using MCS 3.0.0.5 as standalone , and PICBasicPro 2.45A. I do have Mplab V8.0 onboard but they no longer include the ability to compile from basic , and will only work with the *.asm file. If this programme compiles on your system , then it should compile on mine , unless I have a dodgy software loading.. I am about to remove PicBasicPro and MCS and reload them both.. I will post the results , most probably Monday....Thanks...Rod.

mackrackit
- 20th June 2008, 11:44
This tells how to use PIC BASIC and MPLAB together.
http://www.melabs.com/support/mplab.htm

Works very well. I even use this on my Linux box.

Old Man Emu
- 21st June 2008, 11:53
I am happy to announce that , after replacing the HDD in my desktop and reloading both MPLAB and PicBasicPro that I am up and running with my 16F877 compilations..anndd PBPro
is running within MPLAB..