Problem Keeping PORTD.1 LOW - Page 2


Results 41 to 49 of 49

Threaded View

  1. #1

    Question Problem Keeping PORTD.1 LOW

    Hi Picers

    I am designing a project to switch my circuit on with a membrane keypad using a MAX1672 (see attached drawing) with a PIC16F877 @ 20MHz.

    The ONB Pin on the MAX1672, is by default HIGH, to keep the circuit off, if I press the ON button on my keypad it should switch it ON and then in my code I would put PORTD.1 LOW to keep it on, but this does not work.
    When I press the ON button it switch the circuit on, but when I release the button it switch it off again, so my PORTD.1 is not kept LOW.

    I have asked someone on the microchip mailing list if this is a bug, and this is what he has said:

    <hr>
    <i>
    No, it's not a bug. Read-modify-write is just how the chip works:

    When you do a BSF 0x30, 3 the chip does like this:

    1) Read the value at register 0x30 in the ALU.
    2) Change the value of bit 3 (set)
    3) write back the modified value to register 0x30.

    But when a read of a port register takes place, the pin voltage is read, instead of the internal value written to the port. If you have a pullup on the pin, and set it LOW, when you read the pin's value you will get HIGH, because the pullup resistor is forcing it HIGH.

    So, for BSF PORTD,3, the chip does like this:

    A) Read the pins of PORTD in the ALU;
    B) Modify the value of bit 3 (set)
    C) Write back the modified value to register 0x30.

    See? you need to buffer to avoid reading the pins in a r-m-w.

    Eventually they changed the PORT circuitry in the 16bits PICs, to include another register, called LATD, which does the same thing as our PORTD_BUFFER above.
    </i>
    <hr>

    Is there a solution for this in PICBASIC?
    Attached Images Attached Images  
    Last edited by koossa; - 31st August 2005 at 18:22.

Similar Threads

  1. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  2. confused problem with interrupt in a working program
    By illuminator4 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th November 2008, 17:01
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Problems with RC2 and RC3
    By Christopher4187 in forum General
    Replies: 11
    Last Post: - 29th May 2006, 17:19
  5. 4-line LCD Help - using PortA instead of B
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 31st March 2005, 03: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