Pic Basic pro code Compiling help!


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default Pic Basic pro code Compiling help!

    Hello, I have a code built in Pic Basic Pro, but I want to add on a reset to this code so the circuit resets every 30 seconds. I think I have the code correct, however I don't have a compiler or the money to purchase at the moment. The free compilers only allow 2k and this file is around 4k. Would anyone be interested in compiling this to a hex file for me? I would appreciate it.
    Here is the original code-

    @ Device PIC12F675,PROTECT_OFF,INTRC_OSC_NOCLKOUT,MCLR_OFF
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50








    CMCON=7
    GPIO=000000
    TRISIO=0110
    ANSEL=111110
    ADCON0=001100


    t VAR WORD
    c VAR WORD
    cl VAR WORD
    m VAR BYTE
    hh VAR BYTE
    ch VAR BYTE
    u VAR BYTE
    d VAR BYTE


    u=0
    d=0
    hh=2
    ch=1
    cl=0


    pause 250
    ADCIN 3, t
    ADCIN 2, c
    if(t>c) then
    cl=t-c
    m=1
    endif
    if(t<c) then
    cl=c-t
    m=0
    endif


    loop:


    ADCIN 3, t
    ADCIN 2, c
    if m=1 then
    t=t-cl
    else
    t=t+cl
    endif


    if u>10 then
    GPIO.0=0
    GPIO.5=1
    endif


    if d>10 then
    GPIO.5=0
    GPIO.0=1
    endif


    if t>(c+ch) then
    u=u+1
    d=0
    goto loop
    else
    if t<(c-hh) then
    d=d+1
    u=0
    goto loop
    endif
    endif


    u=0
    d=0
    GPIO.0=0
    GPIO.5=0
    nap 2
    GoTo loop

    And here is the code that I need to Compile to a Hex file with the 30 second timer reset function that I think is correct. any help is appreciated!
    @ Device PIC12F675,PROTECT_OFF,INTRC_OSC_NOCLKOUT,MCLR_OFF
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50








    CMCON=7
    GPIO=000000
    TRISIO=0110
    ANSEL=111110
    ADCON0=001100


    t VAR WORD
    c VAR WORD
    cl VAR WORD
    m VAR BYTE
    hh VAR BYTE
    ch VAR BYTE
    u VAR BYTE
    d VAR BYTE
    l VAR WORD


    u=0
    d=0
    hh=2
    ch=1
    cl=0
    l=0


    pause 250




    restart:


    ADCIN 3, t
    ADCIN 2, c
    if(t>c) then
    cl=t-c
    m=1
    endif
    if(t<c) then
    cl=c-t
    m=0
    endif


    loop:


    ADCIN 3, t
    ADCIN 2, c
    if m=1 then
    t=t-cl
    else
    t=t+cl
    endif


    if u>10 then
    GPIO.0=0
    GPIO.5=1
    endif


    if d>10 then
    GPIO.5=0
    GPIO.0=1
    endif


    if t>(c+ch) then
    u=u+1
    d=0
    goto loop
    else
    if t<(c-hh) then
    d=d+1
    u=0
    goto loop
    endif
    endif


    u=0
    d=0
    GPIO.0=0
    GPIO.5=0
    nap 2




    if l=600000
    GPIO.0=1
    GPIO.5=1
    GoTo restart
    endif
    l=l+1
    GoTo loop

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,519


    Did you find this post helpful? Yes | No

    Default Re: Pic Basic pro code Compiling help!

    Hi and welcome to the forum!

    The PIC12F675 only has 1k so it'll be impossible to fit a 4k program. However, it's not the size of the source file (ie the "text file" containing the program) that matters, it's the size of the compiled .hex file that you actually program into the PIC. I can't think that piece of code would result in more than 1k, not to mention 2k which you say is the limit of the free version (which version is that?).

    Finally, IF l=600000 won't work because l is declared as a WORD (ie 16bits) so it can only hold values between 0 and 65535 and there's a missing THEN on the same line.

    /Henrik.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Pic Basic pro code Compiling help!

    Hello and Thank you, I looked again after you told me that info and It appears as though I have exceeded the maximum number of code lines allowed using the PicBasic Demonstration Compiler so that is the revised issue. -thx

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,519


    Did you find this post helpful? Yes | No

    Default Re: Pic Basic pro code Compiling help!

    You can download PBP3.06 from MELABS site, install it and use it in trial mode for 15 days.

    /Henrik.

Similar Threads

  1. Replies: 17
    Last Post: - 15th March 2013, 23:11
  2. Replies: 8
    Last Post: - 18th January 2013, 23:21
  3. [HELP] PIC code for RDS Decoder TDA7330B
    By juanen19 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 23rd November 2012, 20:08
  4. Which pic? up to date basic chip for 16f877
    By tasmod in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 19th November 2012, 11:26
  5. Compiling and code oddities
    By tasmod in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th November 2012, 10:50

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