1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Extracting BITs from BYTE

Discussion in 'Oshonsoft' started by camerart, Jun 20, 2017.

  1. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    I don't understand, what advantages are there in both methods?
    C
     
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,223
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    As you may know, when you power up your PIC, the memory area holding variables may or may not be cleared to zero.
    [depending on whose compiler you are using]
    So if you used 'x' as a indexing counter variable, it could be loaded with say 3 etc on power up.
    So your increment would start at 3.
    You can either
    Dim x as a Byte ' then
    x=0
    or tick the pop up menu
    I prefer to set variable values in the code.
    E
     
  3. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    I didn't know about clearing variables, I'll try to remember to tick the box, Thanks.
    My version doesn't show 'Initialise variable under the OPTIONS drop down?
    C.
     
    Last edited: Jun 22, 2017
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,223
    Likes:
    644
    Location:
    Ex Yorks' Hants UK

    hi C,
    Look in Program File/Oshonsoft, compare the file dates and sizes, see if they are the same as mine, ref image.
    E

    A02.gif
     
  6. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    Looks like they are.
    C.
     

    Attached Files:

  7. sagor1

    sagor1 Member

    Joined:
    Dec 11, 2014
    Messages:
    52
    Likes:
    2
    Your picture of code with res1 and res2 were both comparing by > 0. That is why I said the ">" is irrelevant, you compare to 0 or 1 with an "=" instead to test the state of a bit.

    I was referring to your original code, and trying to explain why I used "=" instead.
     
    • Thanks Thanks x 1
  8. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Hi S,
    I see now! Thanks. I know the code I was following was written by an 'expert', so why would it be written like that? Written in 'C'
    C.
     
  9. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,093
    Likes:
    330
    Location:
    Brisbane Australia
    ONLINE
    It is sometimes useful to use the greaterthan comparison operator when testing bits other than zero when the compiler doesn't support bit types. If(var & 4 > 0) will work where as if(var & 4 == 1) will not. However, it's clearer to use if(var & 4 == 0) or if(var & 4 != 0). You can also use if(var & 4 == 4) as well. Hope I didn't confuse the subject even more.

    Mike.
     
  10. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    Here's a slightly updated version of yesterdays program. BITS and BYTES
    I am sure there are mistakes, feel free to point any out.
    I now have to understand how the FIFO works, to finish the program.
    C.
    Hi M,
    I've just updated the full program using Sagor's code, which I will test. If it fails then please remind me and I'll try your suggestion.
    http://www.electro-tech-online.com/...ceiving-using-scr-radio-modules.149198/page-7
    Thanks, C.
     
    Last edited: Jun 23, 2017
  11. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,093
    Likes:
    330
    Location:
    Brisbane Australia
    ONLINE
    As I said, it's only useful if the compiler doesn't support the bit type. Yours does so just use the equals operator.

    Mike.
     
  12. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Ok, Ta. C.
     

Share This Page