[SOLVED !] How to read 8-bit from 10-bit port?


Today 18:40
Forum: GPS
Starter: david
Views: 0
Replies: 3
Today 18:19
Forum: Proton Plus Compiler v3
Starter: Les
Views: 0
Replies: 16
Today 15:54
Forum: GPS
Starter: SimonJA
Views: 0
Replies: 14
Go to last post By: tumbleweed
Today 14:37
Forum: The Lounge
Starter: towlerg
Views: 0
Replies: 1
Go to last post By: fanie
Today 14:10
Forum: The Lounge
Starter: John Drew
Views: 0
Replies: 12
Today 12:55
Forum: The Lounge
Starter: fanie
Views: 0
Replies: 18
Today 02:12
Forum: The Lounge
Starter: towlerg
Views: 0
Replies: 5
Today 01:13
Forum: The Lounge
Starter: Tim
Views: 0
Replies: 25
Closed Thread
Results 1 to 5 of 5

Thread: How to read 8-bit from 10-bit port?14 days old

  1. #1
    Junior Member qrppablo's Avatar
    Join Date
    Jan 2019
    Posts
    5
    Thumbs Up
    Received: 1
    Given: 2
    Total Downloaded
    0

    0 Not allowed!

    Default How to read 8-bit from 10-bit port?

    I'm working with PIC24HJ128GP502, so I want to read only the low byte (8-bit) from PORTC (10-bit longer) and write it to a BYTE variable.

    On 8-bit microcontrollers I use this:

    ' ======================

    Symbol MyByte = PORTC

    ' Declare BYTE variable

    dim VAR as BYTE

    ' Read the whole PORTC

    VAR = MyByte

    ' Write to whole PORTC

    MyByte = VAR

    ' ======================

    I'm trying to mask the first 8-bit In PIC24 using And $FF, declaring two variables:

    Dim VAR1 as WORD
    Dim VAR2 as BYTE

    VAR1 = PORTC
    VAR2 = VAR1 And $FF

    But the compiler throws an error (unrecognised, illegal or unresolvable characters found).
    Can I use .LowByte (VAR2 = PORTC.LowByte) instead? and how can I write just 8-bit all at once at PORTC (0-7)?

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Senior Member Mellbreak's Avatar
    Join Date
    Jun 2012
    Posts
    503
    Thumbs Up
    Received: 52
    Given: 22
    Total Downloaded
    2.02 GB

    0 Not allowed!

    Default Re: How to read 8-bit from 10-bit port?

    Welcome to the forum grppablo.


    Try using.....

    VAR2 = VAR1 & $FF

    Page 58 of the Proton 24 manual refers.


    Regards,

    Bob
    Last edited by Mellbreak; 7th January 2019 at 19:52.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Junior Member qrppablo's Avatar
    Join Date
    Jan 2019
    Posts
    5
    Thumbs Up
    Received: 1
    Given: 2
    Total Downloaded
    0

    0 Not allowed!

    Default Re: How to read 8-bit from 10-bit port?

    Quote Originally Posted by Mellbreak View Post
    Welcome to the forum grppablo.


    Try using.....

    VAR2 = VAR1 & $FF

    Page 58 of the Proton 24 manual refers.


    Regards,

    Bob
    Thanks for the response. Now, how can I mask the first 8-bit from PORTC to write in all at once? or just I can do this: PORTC = VAR2?

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Senior Member Mellbreak's Avatar
    Join Date
    Jun 2012
    Posts
    503
    Thumbs Up
    Received: 52
    Given: 22
    Total Downloaded
    2.02 GB

    0 Not allowed!

    Default Re: How to read 8-bit from 10-bit port?

    Well assuming you want the lower 8 bits - i.e. bits 0 - 7 Then you could do something like...


    VAR2 = VAR1 & $0F


    or


    VAR2 = VAR1.Byte0

    Have a look at page 24 of the Proton 24 manual. There are various options.



    Bob

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Junior Member qrppablo's Avatar
    Join Date
    Jan 2019
    Posts
    5
    Thumbs Up
    Received: 1
    Given: 2
    Total Downloaded
    0

    1 Not allowed!

    Default Re: How to read 8-bit from 10-bit port?

    It works. Thank you!

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Remapping port pins and 16 bit port
    By RGV250 in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 5th January 2018, 19:35
  2. Read half of an 8 bit Reg
    By Mr Anderson in forum Absolute Beginners Section
    Replies: 3
    Last Post: 17th January 2017, 12:18
  3. W7 64 Bit Com Port SOLVED
    By PAKirk in forum The Lounge
    Replies: 11
    Last Post: 21st June 2011, 17:53
  4. Port bit setting
    By Max in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 4th May 2009, 12:45
  5. Use an index to set/read a Bit in a Byte variable
    By laserline in forum Wish List / Product Feedback
    Replies: 5
    Last Post: 22nd May 2008, 18:55

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts