Help with code


Closed Thread
Results 1 to 28 of 28

Thread: Help with code

  1. #1
    Join Date
    Jul 2007
    Posts
    48

    Default Help with code

    Hi this is my current code (all)
    I use MicroCode Studio Plus with PICBASIC PRO compiler.

    Code:
    loop:   high portb.1
            pause 500
            low portb.1
            pause 500
            goto loop
            end
    And when I transfer it to my PIC16F648A, my led connected to RB1 doesnt blink (the led is working)

    Its connected like this:



    Someone told me that I might be something with CONFIG Bits but he couldnt help me casue he use assembler..

    Versions:


    Programmer is Wisp628+xwisp2161

    Config fuses, no idea..
    Last edited by xobx; - 12th July 2007 at 15:13.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

  3. #3
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Is this better?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    Is this better?
    A bit...
    Still don't know which version of PBP, MCS+, or MPLAB you are using...
    Don't know which programmer and/or version of software/firmware...
    Don't know which config fuses are set (or at least you THINK are set)...

  5. #5
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Now then..

    And any help would be appreciate..

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    Now then..
    And any help would be appreciate..
    Ok, that's a fair bit better yet...
    Now then...What does the PBP manual say about oscillator selections?
    Also, do a readback of your 'config word' and match it up with the datasheet's explanations.
    What do you come up with?

  7. #7
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Ok, I read some and it seems like the Config is stored in '16F648A.INC', right?

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


    Did you find this post helpful? Yes | No

    Default

    try
    Code:
            @   __config _HS_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
            DEFINE OSC 20
            
    loop:   high portb.1
            pause 500
            low portb.1
            pause 500
            goto loop
            end
    Also, read the following thread, at least POST#1 and POST#5
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    if you're using PM, you will need to use
    Code:
            @   device  pic16F648A, hs_osc, wdt_on, mclr_on, lvp_off, protect_off
    instead of __CONFIG
    Steve

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

  9. #9
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    This worked!

    Code:
    @   device  pic16F648A, hs_osc, wdt_on, mclr_on, lvp_off, protect_off
            DEFINE OSC 20
            
    loop:   high portb.1
            pause 500
            low portb.1
            pause 500
            goto loop
            end
    Thank you!

  10. #10
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    OK, I got another problem now..

    When I compile my code with it doesnt update the .hex file so I cant transfer my new program..

    Whats wrong?

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    OK, I got another problem now..

    When I compile my code with it doesnt update the .hex file so I cant transfer my new program..

    Whats wrong?
    Probably updating the wrong .hex file in the wrong directory...unless it's not fully compiling in the first place (i.e. errors).
    Check the date/time on your file, compare it to the current (last compiled) date/time, then go searching for where you file was saved.
    If you're talking about the programmer itself...you're on your own there...

  12. #12
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Hmm, if I take "save as" and save it to another name and then taking compile again..
    I see a new hex file appear with the new name but it still the same as the old code..

    :/

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    Hmm, if I take "save as" and save it to another name and then taking compile again..
    I see a new hex file appear with the new name but it still the same as the old code..

    :/
    Then you aren't changing the source code...

  14. #14
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Thats what im doing..

    Casue this the source code, right?
    http://img529.imageshack.us/img529/6991/coderm3.jpg

  15. #15
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    Thats what im doing..

    Casue this the source code, right?
    http://img529.imageshack.us/img529/6991/coderm3.jpg
    Yes, but what are you doing to that source code that should cause it to change between compilings?

  16. #16
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    What?

    I first made a easy program that only made RB1 "blink" and I compiled it and transfered it over..

    Then I made this code and when I compiled it the hex file still had the old easy program.

    Code:
    @   device  pic16F648A, hs_osc, wdt_on, mclr_on, lvp_off, protect_off
    DEFINE OSC 20
            
    loop:   
    
            high portb.0
            pause 250
            High portb.1
            pause 250
            high portb.2
            pause 250
            low portb.0
            pause 250
            low portb.1
            pause 250
            low portb.2
            pause 250
            goto loop
            
            
            
            end

    So the Problem is: if I change the source code and compile it doesnt update the hex file.

  17. #17
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    I first made a easy program that only made RB1 "blink" and I compiled it and transfered it over..
    Then I made the code I just posted and when I compiled it the hex file still has the old easy program.
    So the Problem is: if I change the source code and compile it doesnt update the hex file.
    So, the old hex file and the new hex file are exactly the same size and have exactly the same contents, just a different date/time stamp?
    What does the bottom of the screen say when it's done compiling...if anything?

  18. #18
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Yes, it exactly same as the old one..

    You can see how it changes:
    Compiling > Assembling > Success: 82 words used.

  19. #19
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    Yes, it exactly same as the old one..

    You can see how it changes:
    Compiling > Assembling > Success: 82 words used.
    Ok, so the one file with portb.0/portb.1/portb.2 has 82 words used.
    What happens to the same program if you comment out everything under 'loop:' and above 'goto loop', then recompile it?

  20. #20
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    I just found out that if I change something in this the hex file changes

    Code:
     @   device  pic16F648A, hs_osc, wdt_on, mclr_on, lvp_off, protect_off
    DEFINE OSC 20
    But if I change something in the rest off the code the hex file doesnt change..

    :/

  21. #21
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    I restarted my computer and now does it work :/

    Wierd!

  22. #22
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    I restarted my computer and now does it work :/

    Wierd!
    Installed a program and didn't do a restart so Windows internal paths didn't get updated...
    Glad I could help...not...

  23. #23
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    What, I restarted the computer after I installed everything!

    I didnt install and directly started to use MCS+
    Last edited by xobx; - 12th July 2007 at 21:35.

  24. #24
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xobx View Post
    What, I restarted the computer after I installed everything!
    Apparently not...
    Restart it again. Maybe your PIC will program itself with the finished product.

  25. #25
    Join Date
    Jul 2007
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Lets see..

    EDIT: ..nope
    Last edited by xobx; - 12th July 2007 at 22:28.

  26. #26
    Join Date
    Apr 2007
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Wow!

    I think this is the first time I have seen this kind of behavior here.
    (or maybe I am just confussed? Would not be the first time!)

    I did not think it existed on this forum. But I guess I was wrong.

    You can bet dollars to donuts I will think twice (maybe three times) about my questions!

    Good luck xobx. Hope you can figure it out! And PLEASE post what you find so all us Noobs know what happened!

    Best,
    Bill12780

  27. #27
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Xobx,

    There's two buttons on MCS. The one you showed here in your conversation with Skimask was the "compile only". The button next to it is "compile and program". If you use the "compile only button, then you manually open your programmer software and load your .hex into the programmer and go from there. If you use "compile and program" then MCS will compile the program AND open your programmer with the current .hex program ready to go. AT least that's how my MCS is working.

    HTH,

    BobK

  28. #28
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bill12780 View Post
    I think this is the first time I have seen this kind of behavior here. (or maybe I am just confussed? Would not be the first time!)
    I did not think it existed on this forum. But I guess I was wrong.
    You can bet dollars to donuts I will think twice (maybe three times) about my questions!
    Good luck xobx. Hope you can figure it out! And PLEASE post what you find so all us Noobs know what happened!

    Best,
    Bill12780
    Ask all the questions you want! I'm all over it...BUT...
    Sometimes you just have to point out the blatantly obvious to some people, and sometimes people just don't give a person crap to work with...

    "My car doesn't run right...What's wrong with it?"
    How much information can you get out of that to help out with a fix?

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

Members who have read this thread : 0

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