first program 12f683


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Apr 2011
    Posts
    6

    Default first program 12f683

    hello group, this is my first pgm and I'm using 12f683 on breadboard with a pickit2 programmer in MPlAB IDE v.8.46 , not compiling, the compiler chokes
    on this code , what simple thing am I doing wrong. I have no problem programming in ASM to this chip

    '************************************************* ***************
    '* 12F683.BAS *
    '* *
    '* By : Leonard Zerman, Jeff Schmoyer *
    '* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
    '* All Rights Reserved *
    '* Date : 05/14/04 *
    '* Version : 2.45 *
    '* Notes : *
    '************************************************* ***************

    BANK0 $0020, $007F
    BANK1 $00A0, $00BF
    EEPROM $2100, $21FF
    LIBRARY "PBPPIC14"
    DEFINE CCP1_REG GPIO
    DEFINE CCP1_BIT 2

    include "PIC14EXT.BAS"

    PORTL VAR GPIO
    PORTH VAR GPIO
    TRISL VAR TRISIO
    TRISH VAR TRISIO

    include "PBPPIC14.RAM"

    main:
    goto main

    '*-----------------------* EOF 12F683.BAS *---------------------*

    Output:


    Executing: "C:\PBP\PBPMPLAB.BAT" -ampasmwin -k# -p12F683 "C:\PBP\12F683.BAS"
    Executing: "C:\PBP\PBPW.EXE" -ampasmwin -k# -p12F683 "C:\PBP\12F683.BAS"
    PICBASIC PRO(TM) Compiler 2.60, (c) 1998, 2009 microEngineering Labs, Inc.
    All Rights Reserved.

    C:\PBP\PIC14EXT.BAS ERROR Line 11: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 12: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 13: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 14: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 15: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 16: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 17: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 18: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 19: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 20: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 21: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 22: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 23: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 24: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 25: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 26: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 27: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 28: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 29: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 30: Redefinition of VAR.
    C:\PBP\PIC14EXT.BAS ERROR Line 31: Redefinition of VAR.
    FATAL ERROR: Too many errors. (21)
    Halting build on first failure as requested.
    BUILD FAILED: Tue Apr 19 13:32:22 2011

  2. #2
    Join Date
    Apr 2011
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    OK, I commented out several lines to get the compiler to stop choking and added some asm to get this started


    '************************************************* ***************
    '* 12F683.BAS *
    '* *
    '* By : Leonard Zerman, Jeff Schmoyer *
    '* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
    '* All Rights Reserved *
    '* Date : 05/14/04 *
    '* Version : 2.45 *
    '* Notes : *
    '************************************************* ***************

    BANK0 $0020, $007F
    BANK1 $00A0, $00BF
    EEPROM $2100, $21FF
    'LIBRARY "PBPPIC14"
    'DEFINE CCP1_REG GPIO
    'DEFINE CCP1_BIT 2

    ' include "PIC14EXT.BAS"

    'PORTL VAR GPIO
    'PORTH VAR GPIO
    'TRISL VAR TRISIO
    'TRISH VAR TRISIO

    ' include "PBPPIC14.RAM"

    ASM
    BANKSEL TRISIO
    MOVLW B'01100000' ;4mhz
    MOVWF OSCCON
    BCF TRISIO,5 ;GP5 output
    ENDASM
    start:
    LOW PORTL.5
    PAUSE 500
    HIGH PORTL.5
    PAUSE 501
    goto start

    End


    '*-----------------------* EOF 12F683.BAS *---------------------*

  3. #3
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    The files like 12F683.BAS are meant to be left alone. You should be naming your own file xyz.bas or xyz.pbp, or any name to your liking (that does not exist in PBP). Hopefully you made a copy of the file so you can restore 12F683.BAS back to normal.

    You may sometimes have to edit some configs in files like 12F683.inc, but changing configs should be it. Don't write a program there.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    If you need some examples to play with take a look here.
    http://melabs.com/samples/PBP-mixed/index.htm
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Apr 2011
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    thanks,I'm aware of that copy mistake but I dont know why I have to comment out parts of the .bas file to get it to compile with this simple test code

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    That was/is not test code. It is part of the "guts" of PBP just like the *.inc files in the same directory.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Apr 2011
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    here is the steps I have taken in MPLAB
    1.click project wizard and select 12f683 and save project as test-12f683.mcp
    2. copy file 12f683.bas to folder and rename it test-12f683.bas
    3. click finish and project is complete
    add 2 lines of code
    main:
    goto main

    press f-10 to compile and the program chokes
    then I comment out several items and now it will compile
    this does not seem right

    my code will run on the micro. just want make sure that this is the right way




  8. #8
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    Quote Originally Posted by sparkness View Post
    just want make sure that this is the right way


    No, you are not supposed to put code in, and compile the guts of PBP, like this file. Please re-read posts above.

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    Again, that is not a sample or test code. You should not be trying to run it, it is a file PBP needs to help compile code.

    Restore the file to its original state and try one of the smples I linked you to.
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Apr 2011
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    so I should not add the source file 12f683.bas to the project and create an empty file called test-12683.bas in this example?

  11. #11
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    You got it.

    Or you can try running one from melabs, like Dave suggested.
    http://melabs.com/samples/LABX4-12F68x/

    Code:
    ' Name        : BLINKX4.pbp
    ' Compiler    : PICBASIC PRO Compiler 2.6
    ' Assembler   : PM or MPASM
    ' Target PIC  : PIC12F683
    ' Hardware    : LAB-X4 Experimenter Board
    ' Oscillator  : 4MHz internal
    ' Keywords    : 
    ' Description : PICBASIC PRO program to blink an LED connected
    ' to GPIO.0 about once a second.
    '
    
    LED Con 0        ' Alias GPIO.0 to LED
    
       ANSEL = 0     ' Set all digital
       CMCON0 = 7    ' Analog comparators off
    
    mainloop:
       Low LED       ' Turn on LED connected to GPIO.0
       Pause 500     ' Delay for .5 seconds
       High LED      ' Turn off LED connected to GPIO.0
       Pause 500     ' Delay for .5 seconds
       Goto mainloop ' Go back to mainloop and blink LED forever
    
       End

  12. #12
    Join Date
    Apr 2011
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    my mistake, I was adding the .bas file to the project
    I was using the steps required for an Assembler project

  13. #13
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    I'm back with a stupid questions. I want to turn on a led when RC signal is > 1,6ms , but my led is off all time. Please,can somebody explain me why my code not work?

    1000x thx

    code:

    ansel = 0
    wpu = 0
    cmcon0 = 7
    signal var word

    main:

    Pulsin gpio.3,1,signal
    if signal > 1600 then high gpio.0

    goto main
    end

  14. #14
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    i solved... the problem was from CONFIG . MCLRE must be off and measured pulse is in 10us.

    #CONFIG
    __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    #ENDCONFIG

    ansel = 0
    wpu = 0
    cmcon0 = 7
    signal var word

    main:

    pulsin gpio.3,1,signal
    if signal > 160 then high gpio.0


    goto main
    end

  15. #15
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    Hi,

    you also must add in your program the condition for the led to be off ...

    as outputs are bistable kind ... they will stay on the last programmed state, otherwise stated ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  16. #16
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: first program 12f683

    Thx Alain! I try to learn about microcontrolers and any info are welcome.

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