Timer PIC16F57


Closed Thread
Results 1 to 26 of 26

Thread: Timer PIC16F57

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default blinky light

    Iīm sorry to start by a blinky light, but my english itīs not good to explain in detaill all things, so iīve put a simple question
    Iīm used to finish with endif, but if itīs better for my code space iīll follow your advise!
    Just another question: my code after compiling gives me this warning " "Crossing page boundary -- ensure page bits are set." i donīt have to worry, because PBP takes care of this problem???!!! I donīt have any branch instruction so thatīs ok (pag.13 of PBP manual), my code will work great! Correct?

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Leonel,

    Leonel
    Iīm sorry to start by a blinky light, but my english itīs not good to explain in detaill all things, so iīve put a simple question
    That is fine Leonel... Even I have problems... so you and I are in the same boat together... We can wave flags at each other, and sink with the ship...at least we will have a little fun.

    Iīm used to finish with endif, but if itīs better for my code space iīll follow your advise!
    This is not a requirement Leonel... This is all up to you and your preference. You may code anyway that makes you understand it. I only made a suggestion, to show you a different way how to code. I have been corrected many times on my coding!... Sometimes I change, sometimes I don't. As long as the code compiles, and I understand it... its fine with me.

    Just another question: my code after compiling gives me this warning " "Crossing page boundary -- ensure page bits are set." i donīt have to worry, because PBP takes care of this problem???!!! I donīt have any branch instruction so thatīs ok (pag.13 of PBP manual), my code will work great! Correct?
    You shouldn't have to worry about crossing page boundary... PBP takes care of that... I only question is why??? I don't think you have 2 k of code there... but I could be wrong. But you should not have to worry about this warning.

    Now about your code... If you notice my tag, one of the statements is: "Compile something that runs" There is no guarantee on your code (or my code) running to do the job you want it to do. Since I have no way how to test it, I can only give you code that is Close to what I think you are wanting.

    Remember, the code I am giving you is a "shell" around your "Secret weapon" That shell is taking care of a blinky light, taking care of your 20 and 40 second timing, and also checking your switches. I noticed on your code, that my routine was used as a kind of subroutine. This may get you into a little trouble...with how your program works. But you can try it!...

    Since you said the blinky light can be off by a few seconds, I made the code as a shell. A shell is the part that fits around your program and stuff. What will vary your blinky light, will be the code in my shell. But I am betting that the computer is so fast, that your code will not make that much difference between the blinky lights.

    I also noticed you used a Pause 1000 . That is a 1 second delay...That means if you are pushing a button, you may have to hold it for at least 1 second! If this is ok with you, great.

    My biggest question is:

    Do you fully understand what my code is doing? Do you fully understand that it is a shell, and how it is taking care of the timing, switch checking, and blinky light? Do you know where to insert your code, so that my code will work like it should? I only ask these questions, because it seems you are using it as a kind of Subroutine. (I have not studied your code to fully comprehend it, but I just picked up on a few little things that made me wonder).


    Dwayne
    Last edited by Dwayne; - 30th June 2005 at 16:24.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default Subroutine

    Yes i understand your code and your right, iīm using it with a subroutine, and with your explanation i understand what a shell is (an oil pump )
    I used your code with a little modifications... now i have to build my hardware and test it.
    I know that with pause the program doesnīt check anything, but in this case (only in 2 inputs), thereīs no problem. If you see i'll make some of my outputs high during 20s or 40s with pause. and in this time i donīt want to see any input.

  4. #4
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hell Leonel,

    Ok! Just wanted to make sure!...

    I also noticed you changed my "If" statements to "while" statements.
    Since I do not have a testing ground here, I do not know what will happen, if the program "Jumps" out of the middle of a while statement too many times.
    I have had no problems jumping out of a "If" statement... but I am not sure about a while statement. So, I did not use while statements, for fear of crashing <g>.

    Ralph, Steve, Melanie, Darrel, Bruce... Whats the answer???

    Code:
    Loop
    a=1
    
      while a <100 
        .....
        if a==50 goto Loop
        ...
        a=a+1
      wend
    ....
    goto Loop.
    If a hits 50 a bunch of times, will this give PBP a problem and lose its stack? or run haywire? I know in some older versions of C/C++, it could cause a problem with memory...but I am not sure in PBP.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  5. #5
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default help

    To be honest i donīt know the answer too! If anyone can help us...
    In all my experience (10 months in PBP ) i didnīt have problems, but... thereīs always a but!

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


    Did you find this post helpful? Yes | No

    Default

    personnaly if i want to jump out of a while statement i would prefer to validate the WHILE condition and set a JUMP or FLAG bit to do XYZ task...

    well code will talk by itself...

    Code:
    Start:
         While AVar!=50
              if AVar==20 then 
                   AVar=50
                   FlagBit=1
                   endif
              Wend
         IF FlagBit=1 then Start
    BUT i would also prefer another approach... like two WHILE statement one after the other... case by case i guess.

    I don't belive that the Stack will be a problem since it's not a GOSUB...
    Steve

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

  7. #7
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Steve,

    Steve>>i would prefer to validate the WHILE condition and set a JUMP or FLAG bit to do XYZ task...<<

    Great minds think alike <grin>... (Hope you don't take that as a insult)

    I am like you... I like to force the while to do its job...

    Thanks Bud!... I hope things are well in Canada...

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  3. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 07:56
  4. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  5. timer interupt help 16f73
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd July 2005, 08:41

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