PDA

View Full Version : ERROR Compling 16F819...l but the 16F818 works fine



4Lewis
- 20th April 2006, 05:01
I get an error when I compile for the 16F819... the same code works for the 16F818. Explaination?
---------------------------------------
DEFINE OSC 4
DEFINE ADC_BITS 10 'Set number of bits in result
DEFINE ADC_CLOCK 3 'Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 'Set sampling time in us


TRISA = %11111111 'Set A to inputs
TRISB = %00000000 'Set I/O to output
ADCON1 = %10000010 'Port A Analog and right justify results


X VAR BYTE

LOOP:
ADCIN PORTA.1, X
Pause 50
If X > 100 Then
GOTO BLINK
ENDIF
GOTO LOOP

BLINK:
HIGH PORTB.4
Pause 100
LOW PORTB.4
RETURN

---------------------------------
Here's the error msg:
Error [124] C:\PROGRA~1\PICBAS~1.16\PBPPIC14.LIB [Illegal Argument]

paul borgmeier
- 20th April 2006, 05:23
Compiles fine for me on the 818 and the 819 (I use MPASM).

However, your troubles could be due to the “Return” at the end of the Blink section. Did you intend to use “Gosub Blink” instead of “Goto Blink” in the Loop Section?

Paul Borgmeier
Salt Lake City, Utah
USA

4Lewis
- 20th April 2006, 12:56
Your suggestion of using "goto" did not work.

Melanie
- 20th April 2006, 13:13
If you add -v to your command line when compiling, it should highlight the offending line during the compilation process to give you a clue where to look.

As Paul said you should be using GOSUB BLINK because you are calling a subroutine, and not GOTO BLINK as in your original post, which makes me suspect that the code you posted on the forum is not exactly the same as the code you have in your working program, because you will get a Stack Underflow the instant your try to run it on a PIC.

4Lewis
- 20th April 2006, 13:19
------ I should have stated I am using the complier that comes with PidBasic Pro called MicroStudio, so I don't know how to do the command line option you suggested. Thank you though ----

If you add -v to your command line when compiling, it should highlight the offending line during the compilation process to give you a clue where to look.


I have tried both "goto and gosub" with same result... I'll try again this morning and see what I can get! (fingers crossed)

"As Paul said you should be using GOSUB BLINK because you are calling a subroutine, and not GOTO BLINK as in your original post, which makes me suspect that the code you posted on the forum is not exactly the same as the code you have in your working program, because you will get a Stack Underflow the instant your try to run it on a PIC. "

Melanie
- 20th April 2006, 13:47
It's probably a setting in your Microcode Studio (which I don't use). The reason I say that is that the only difference between a 16F818 and 819 is the memory. PICBasic will not give you a clean compile on the 818 and then an error on the 819. Sometimes I think IDE's give you more problems than they're worth.

mister_e
- 21st April 2006, 02:54
Eveybody can have their own opinion about any IDE but in this case it's not the problem source. In fact, since i use MicroCode Studio i'd never ever have a problem related to the IDE when compiling the code, using the Serial Monitor, Bootloader or else component of.

NOW, let's see where it may crash...


ADCIN PORTA.1, X

Come on.. read carefully the PBP manual, you must write the channel number not the PORT PIN name


ADCIN 0,x


true about the Goto Gosub, you must write as


Pause 50
If X > 100 Then
GOSUB BLINK
ENDIF
GOTO LOOP


BUT, i also suspect of a corrupted file in your PBP folder. remove PBP then reinstall it.

That's definately NOT an IDE problem. Work here with PM and MPASM with both PIC EVEN if i keep the Goto instead of using the GOSUB. I'll keep my own 'flames' about IDE.

4Lewis
- 21st April 2006, 06:47
Well the following code got rid of that strange error... now the LED blinks no matter what the variable number is. So another issue to tackle... whoa is me.

"'''''''''''''''''''''''''

Define OSC 4
''''''''''''' DEFINE Analog Stuff '''''
Define ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SEAMPLEUS 50

ADCON1= %10000010 'Set PortA analog and right justify
TRISB = %00000000 'set PortB to output
TRISA = %10111111 'set A.0-5,7 as input/ A.6 as output

'MAKE A VARIABLE TO HOLD THE NUMBER!
Selection var byte

Main:
adcin 1,selection
serout2 PortB.6,16468,[DEC Selection, 10, 13]
If Selection > 100 Then
Gosub BLINK
ENDIF
goto Main


BLINK:
High PortB.3
Pause 200
Low PortB.3
GOTO Main

'''''''''''''''''''''''