ERROR Compling 16F819...l but the 16F818 works fine


Closed Thread
Results 1 to 8 of 8
  1. #1
    4Lewis's Avatar
    4Lewis Guest

    Unhappy ERROR Compling 16F819...l but the 16F818 works fine

    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]

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    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

  3. #3
    4Lewis's Avatar
    4Lewis Guest


    Did you find this post helpful? Yes | No

    Default Good try

    Your suggestion of using "goto" did not work.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    4Lewis's Avatar
    4Lewis Guest


    Did you find this post helpful? Yes | No

    Default

    ------ 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. "

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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...
    Code:
    ADCIN PORTA.1, X
    Come on.. read carefully the PBP manual, you must write the channel number not the PORT PIN name
    Code:
    ADCIN 0,x
    true about the Goto Gosub, you must write as
    Code:
    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.
    Last edited by mister_e; - 21st April 2006 at 04:02.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    4Lewis's Avatar
    4Lewis Guest


    Did you find this post helpful? Yes | No

    Default works... sort of

    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

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

Similar Threads

  1. Replies: 1
    Last Post: - 23rd May 2009, 10:22
  2. 7805 works fine, LM2940CT5 not!
    By DanPBP in forum Off Topic
    Replies: 4
    Last Post: - 29th August 2007, 23:01

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts