PIC's ports individual bits manipulation - how to?


Results 1 to 39 of 39

Threaded View

  1. #25
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    I might have misread the original intent, but you did ask:

    How is it possible to handle ONLY those four bits wihtout modifying the other (MSB) four bits?
    "Under the hood" PBP will either write to the port as a Byte, or set/clear individual bits. This means you have 2 basic approaches:
    1) Dave's approach, which deals with the port as a byte. This uses some bit manipulation to preserve the status of the MSBs.
    2) And what I was trying to get at, but was not very clear, and that is to set each bit individually.

    Just so I've got it straight, as your FOR...NEXT loop counts from 0 to 3 you would like to see a pattern on PORTAs LSB like: 0001, 0010, 0100, 1000. Is this correct?

    If this is the case, then this should work:

    Code:
    Digit VAR Byte
    DCD_temp VAR Byte
    
    FOR Digit = 0 TO 3
         DCD_temp = DCD Digit 
         PORTA.0 = DCD_temp.0
         PORTA.1 = DCD_temp.1
         PORTA.2 = DCD_temp.2
         PORTA.3 = DCD_temp.3
    NEXT Digit
    SteveB
    Last edited by SteveB; - 26th February 2007 at 05:53.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Individual Variable bits
    By tazntex in forum General
    Replies: 4
    Last Post: - 31st January 2008, 18:27
  3. Equating Ports to Data Bits
    By Osiris in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd March 2006, 15:00
  4. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31
  5. pics with 3 hardware PWM ports
    By CBUK in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th August 2004, 00:14

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