Memory Space of the PIC16F84...


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Tear's Avatar
    Tear Guest


    Did you find this post helpful? Yes | No

    Default

    Thank you SOOOOOOO much Steve!!!!!! This code is exactly what I need to make it work! My poor, unefficent code was doing the job, but this is so much cleaner and easier to use!

    I defiantly have a lot of learning to do. This was my first attempt at writing my own program.

    Also, with your version of this code I save nearly half the words!

    I have been studying the way you have wrote this code and I dont understand how this line works. I understand what it does but not how. I am just curious on this one?

    pb=(PORTB>>5)& 3 ' keep only PORTB.5 and PORTB.6 bits

    Thanks,
    Michael
    Last edited by Tear; - 1st July 2005 at 15:49.

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


    Did you find this post helpful? Yes | No

    Default

    Great, but there's a tons of way to it more efficient. i was just trying to do something readable. Glad to know it's work as you wish. Hard to test when you're out of the city in a hotel room with a simple laptop.

    BTW let's look at
    pb=(PORTB>>5)& 3 ' keep only PORTB.5 and PORTB.6 bits


    this line read the whole PORTB and shift bits 5 position to the right and finnaly do a bitwise AND with 3.
    WHY... easier to read...and get only push buttons state

    let's see how it's work.

    Let's assume that PORTB=%11100000
    after >>5 = we have %00000111
    after & 3 we have %00000011 = 3 => both push buttons

    Of course we an also use PB=PORTB & %01100000
    and modify the Increase, decrease and Both constant definition too. That will save some code space and will do the same job. Or skip the Constant definition and place the expected value in the Select Case, or, or or , or...Posibility are endless.

    Sometimes, there's a choice to do. Having a readable code or a less readable but really tight. It's case by case.

    My last project use a 18F4620 and the full 64K of code. I spent many hours to shrink it as i can each time i add a new feature BUT I was out of codespace to implement new feature(on customer request)and i spend several hours to shrink everything by using PBP macro and do some workaround. Less readable but work as well as it suppose to.

    Great to know it's working fine for you.

    Have fun!
    Steve

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

Similar Threads

  1. 'reserving' memory space
    By comwarrior in forum General
    Replies: 11
    Last Post: - 25th September 2009, 22:37
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  3. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 00:22
  4. Replies: 4
    Last Post: - 2nd March 2007, 06:12
  5. Use internal program memory like DATA memory
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th December 2006, 18:38

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