Program compiles and writes but can't run


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Program compiles and writes but can't run

    I am new to PICBasic Pro and the PICkit2 Starter Kit which I just purchased. I could get the PCBDemo to run via the PICkit2 with the PIC16F690 that came on the Demo board. However, when I tried run one of the sample programs that comes with PCIBASICPro Demo (SLEEP.bas), it compiles OK with MCS and I can import the resulting hex file into PICkit2 and target the device. It appears to write to the device OK, although the Verify finds an error mismatch in the Data memory, which I presume is not critical since the device has not executed the program yet or created any stored data.
    However, when I try to run the program that was written to the device by clicking the box for /MCLR the program doesn't run. Here is the code I am trying to run which is very simple. Can anyone advise me what I may be doing wrong :in trying to run this program in PICkit2??
    'SLEEP Command
    'Slowly blink LED using low power mode delay

    LED CON 16 'Identify LED pin

    Loop:
    TOGGLE LED
    SLEEP 10
    GOTO loop

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    There is a little check box called ON listed below the text, VDD PIC Kit 2, it must be checked to power your demo board from the usb.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    There is a little check box called ON listed below the text, VDD PIC Kit 2, it must be checked to power your demo board from the usb. Here is a sample that works on that board.
    Code:
    ;@MyConfig =  
    @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON  
    @MyConfig = MyConfig & _MCLRE_ON & _BOR_OFF 
    @ __config  MyConfig 
    
    DEFINE OSC 4
    PortA = 0
    PortB = 0
    PortC = 0
    TRISA = 1
    TRISB = 0
    TRISC = 0
    i var byte
    ANSEL = 0
    ANSELH = 0
    CM1CON0 = 0
    CM2CON0 = 0
    main:
    
    portc = 0
    pause 500
    
    for i = 1 to 15; step -1
    
    
    portC = i
    i=i  << 1 
    pause 250
    next i
    sound portB.6, [120,2,124,2,123,2,121,2]
    sound portC.6, [120,2,124,2,123,2,121,2]
    goto main
    end
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Can't run program

    I already had the VDD PICK2 On box checked to power up the Demo board.

    I tried to compile the code sample you provided that you say runs with this Demo board and I get a error 118...Overwriting previous address contents., and a large number of Errors #113..Symbol not previously defined.

    Any other suggestions as to how to get the program to run??

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jellis00 View Post
    I already had the VDD PICK2 On box checked to power up the Demo board.

    I tried to compile the code sample you provided that you say runs with this Demo board and I get a error 118...Overwriting previous address contents., and a large number of Errors #113..Symbol not previously defined.

    Any other suggestions as to how to get the program to run??
    Ok, that is easy. In the PBP root directory there are files named for the PIC you are using, ending with the suffix .inc and in these files are "DEFAULT" config statements, like the one at the beginning of the code I listed. Open the 16F690.inc file located there and find the config line, The MPASM config line will say this
    Code:
    __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    Add an ; semicolon like so
    Code:
    ;__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    and that will solve the overwrite issue, you will for evermore have to include a config line into the code you write for this chip unless you change it back. OR you might try commenting it out in my code. Let's face it, the DEFAULT configs are there so noobies can get some code to run without knowing anything about config fuses, personally I think they serve to confuse people more than help, better I say, put this information in the manual and all the books on PICs.<br>By putting the configs in your code, it becomes easy to change oscillator, and MCLRE statements etc . . .<br><br>Now as for Symbol not previously defined, 2 main causes are inaccurate choices of symbols like BOR or MCLRE and others too, and The other MAIN reason is not having selected the correct PIC in Microcode Studio, and since I KNOW this code is correct, I would say that is the problem there. I notice it gets changed sometimes (which PIC is selected ) from the last I ran it. So you need to always check that first on compile failure with symbol error.
    Last edited by Archangel; - 21st March 2009 at 05:59.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Program won't run

    OK, I understand about editing the include file.
    However your instructions on selecting the right PIC in MicroCode Studio confuse me....I went thru all the menus in MSC and couldn't see where to do that. Please advise how I do that in MSC.

  7. #7
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Program won't run

    Joe S., I commented out the line in the include file per your instructions and tried to compile again and still get all the 113 errors. ?????
    Did I mention that I am using the PICBASIC PRO Demo compiler that came with the PICkit2 Starter Kit and not a production version of PICBASIC PRO Demo.....would that make a difference?

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jellis00 View Post
    Joe S., I commented out the line in the include file per your instructions and tried to compile again and still get all the 113 errors. ?????
    Did I mention that I am using the PICBASIC PRO Demo compiler that came with the PICkit2 Starter Kit and not a production version of PICBASIC PRO Demo.....would that make a difference?
    Hmmm I don't know beans about the Demo version except you are limited as to how many lines of code it will run. Try removing the sound lines and any blank lines and try again, also try removing the code relating to unused ports, namely porta and b, or better yet try this, with the 16f690.inc file unaltered.
    Code:
    DEFINE OSC 4
    LED_1 VAR BIT  ' PORT FLAG BIT
    LED_1 = 0      ' SET INITIAL VALUE
    TRISC.0 = 0 ' Make PORTC.0 an output
    
    
    Main:
    IF LED_1 = 0 THEN
    LED_1=1
    ELSE
    LED_1 = 0
    ENDIF
    PORTC.0 = LED_1
    
    
    
    
    PAUSE 250 ' Delay for 1 second (compiler errors with this line - I guess the command isn't right!)
    Goto Main ' Loop forever
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  9. #9
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Program won't run

    Joe S.,
    Interestingly, when I copied this code int a Workspace project I created in MPLAB with PICkit2 set as programmer and PICBASIC Pro set as language, it compiles without any errors and will program into the PIC16F690 via the PICkit2 programming interface. It work as advertised this way.
    However, if I copy the same code into MCS and try to compile it (with the PIC16F690.incl either normal or edited per you instructions) it creates all of the same 113 and 118 errors about not licking the symbols or overwriting....the original problem I observed.
    I wanted to use the MCS/PICkit2 programming environment, but if I can't get it to compile the programs I will just have to use the MPLAB environment setup to operate with PICkit2. The reason I wanted to use MCS is because of its context help feature on PICBASIC syntax. I guess I can still write programs in MCS and then copy them into a Workspace on MPLAB for programming, but this is extra steps I wanted to avoid.

  10. #10
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Program won't run

    Joe S.,
    You didn't answer my one question in an earlier email regarding your instructions "The other MAIN reason is not having selected the correct PIC in Microcode Studio...." Since this may be causing the unrecognized symobl error, can you please tell me how to make the PIC selection in MCS? I looked thru MCS and couldn't see how to do that.

  11. #11
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jellis00 View Post
    Joe S.,
    Interestingly, when I copied this code int a Workspace project I created in MPLAB with PICkit2 set as programmer and PICBASIC Pro set as language, it compiles without any errors and will program into the PIC16F690 via the PICkit2 programming interface. It work as advertised this way.
    However, if I copy the same code into MCS and try to compile it (with the PIC16F690.incl either normal or edited per you instructions) it creates all of the same 113 and 118 errors about not licking the symbols or overwriting....the original problem I observed.
    I wanted to use the MCS/PICkit2 programming environment, but if I can't get it to compile the programs I will just have to use the MPLAB environment setup to operate with PICkit2. The reason I wanted to use MCS is because of its context help feature on PICBASIC syntax. I guess I can still write programs in MCS and then copy them into a Workspace on MPLAB for programming, but this is extra steps I wanted to avoid.
    It is funny, the program never failed to compile and load from MCS through PICKit2. That said, it did say cancelled at the bottom, until I cut and pasted it into a new page in MCS and saved it as another name, it then compiled and said success. You and I might both need to reinstall MCS. The other code example I gave you . . . Did it work for you in MCS ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jellis00 View Post
    OK, I understand about editing the include file.
    However your instructions on selecting the right PIC in MicroCode Studio confuse me....I went thru all the menus in MSC and couldn't see where to do that. Please advise how I do that in MSC.
    Do you have the "compile and program" tool bar turned on?
    If not go to view and select it from the tool bar option.
    Then you should see a drop down list box with the supported chips.
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Thumbs up Program wont' run

    Quote Originally Posted by Joe S. View Post
    The other code example I gave you . . . Did it work for you in MCS ?
    Joe S., No, neither of the code sets would compile in MCS.

    However, I think MACKTRAP led me to the solution. Once I did turn on the toolbar and set the device to PIC16F690 I was able to compile and program from MCS via PICkit2 for the code sets Joe S. provided as well as my other code samples I could not get to run.

    Thanks so much to both of you for helping me resolve this problem.

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


    Did you find this post helpful? Yes | No

    Default

    MACKTRAP
    ??????

    I have heard worse.
    Dave
    Always wear safety glasses while programming.

  15. #15
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by jellis00 View Post
    LED CON 16 'Identify LED pin
    Which port should this be ???????
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  16. #16
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    49


    Did you find this post helpful? Yes | No

    Default

    jellis00,

    I do have the same problem before if I used MPASM to compile. Check your setting and don't use MPASM to compole.
    I dont know whats the problem cause I'm still new but my program run smoothly without using MPASM. You should give a try.

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