Equating Ports to Data Bits


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Osiris's Avatar
    Osiris Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Melanie,

    Thanks for the explanation. Indeed I had no choice but to scatter my bus around because some of my port bits are for dedicated hardware and since the pins have special features (like hardware interrupt, HUART, HPWM, etc) I had no choice but to scatter them about.

    My worry is that I did try the following:

    Myword Var word

    Myword.0=PortA.3
    Myword.1=PortB.7
    ...
    Myword.15=PortC.4


    But when I write the following statement it does not transfer the configuration to the port:

    newdata var word

    Newdata = 1234
    Myword = Newdata

    I would assume it would transfer the bit pattering from "newdata" to "myword" which would then output the bits on the associated ports.

    It seems too simple of a problem and at the back of my head I have a feeling that I'm missing something very fundamental which does not allow the program to work.

    Many thanks,
    Osiris

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    In your first example...

    Myword Var word

    Myword.0=PortA.3
    Myword.1=PortB.7
    ...
    Myword.15=PortC.4

    ...you transfer the contents of the Port Pins into your variable.

    Newdata = 1234
    Myword = Newdata

    Now the above two lines stuffs Myword with the contents of Newdata ie 1234.

    If now you want that to appear on the Port Pins, you have to do the reverse of what you originally did... ie...

    PortA.3=Myword.0
    PortB.7=Myword.1
    ...
    PortC.4=Myword.15

    Remember Myword is a RAM variable, not a Port alias.

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 05:47
  2. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 03:21
  3. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 15:50
  4. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 15:31
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 29th November 2004, 00:56

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