Announcement

Collapse
No announcement yet.

Serout() a word by bitwise shift?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Serout() a word by bitwise shift?

    Hi,
    I need to send the HIword & LOword of media_SetSector via serout(), so I do this?
    serout(HIword

  • #2


    serout(HIword>>8);serout(HIword);serout(LOword>>8);serout(LOword); Maybe?
    Mark

    Comment


    • #3


      Thanks but I don't quite understand. Unless I'm wrong, since it is media_SetSector, shouldn't the max value for HIword & LOword be 128? If so, in 4DGL, does it mean this value is stored in MSB? And, since I only need 1 byte, I don't need the other, right?

      Comment


      • #4


        media_SetSector takes two WORD Parameters, a word is 16 bits, so the total sector parameter is 32 bits long.

        eg for the sector number below

        0x12345678

        The highword parameter would be 0x1234 and the lowword parameter would be 0x5678

        16 bits can contain 2^16 or 65536 values

        A 2 gig uSD card has over 4 million sectors

        Does that help you understand what is going on?
        Mark

        Comment


        • #5


          Thanks for the detailed explaination. I understand the WORD size & media_SetSector() but since serout() sends a byte-size & you wrote serout(HIword>>8) then serout(HIword), I'm just trying to understand this portion.
          Base on your example:
          sector = 0x12345678, so HIword = 0x1234
          serout(HIword>>8) => serout(0x12) ?serout(HIword) => serout(0x34) ?

          Comment


          • #6


            Correct......
            serout() only sends the low byte of the word value you pass to it....
            (HIword>>8) = 0x0012, so serout(HIword>>8) sends out the byte 0x12
            serout(0x1234) sends out the byte 0x34......
            _______________
            Best Regards,
            Howard

            Comment


            • #7


              OK, cool. Thanks!

              Comment

              Working...
              X