+ Reply to Thread
Page 3 of 3
First 1 2 3
Results 31 to 34 of 34

Thread: PIC16F631 and Port not going low again

  1. #31
    mike50 Okay
    Join Date
    Jun 2007
    Location
    Rochester, Minnesota
    Posts
    102

    Default

    Quote Originally Posted by Nayth View Post
    I have set OPTION_REG.7 = 1 and it dosn't help, the port still stays high once I've had an input on it.

    Turns out that it's my delay rutine

    Code:
    void delay10( char n) //delay10( 100);  /* 1 second */
    /*
      Delays a multiple of 10 milliseconds using the TMR0 timer
      Clock : 4 MHz   => period T = 0.25 microseconds
      1 IS = 1 Instruction Cycle = 1 microsecond
      error: 0.16 percent
    */
    {
        char i;
    
        OPTION = 7;
        do  {
            clrwdt();  // only if watchdog enabled
            i = TMR0 + 39; /* 256 microsec * 39 = 10 ms */
            while ( i != TMR0)
                ;
        } while ( --n > 0);
    }
    
    If I disable a call to this function that is being called from my Running_Led() function it all works, except for the fact that there's no delay in the lights being turned off and on, so they look like they are all turned on at the same time, when in fact they are turning on and off faster than I can see it.

    I think it has something to do with the OPTION = 7, but I am not totally sure.
    OPTION is the OPTION_REG register; that IS your problem.

    Setting OPTION_REG to 7 means setting it to 0b00000111, which sets OPTION_REG.7 to 0, thus enabling the weak pull-ups.

    Mike
    Last edited by mike50; 12th May 2009 at 10:46 PM.


  2. #32
    Nayth Newbie
    Join Date
    Apr 2009
    Posts
    21

    Default

    Would it be possible to add OPTION_REG.7 = 1 to the code after the OPTION = 7 or change OPTION = 7 to OPTION = 135 which should be 0b10000111?

  3. #33
    mike50 Okay
    Join Date
    Jun 2007
    Location
    Rochester, Minnesota
    Posts
    102

    Default

    Quote Originally Posted by Nayth View Post
    Would it be possible to add OPTION_REG.7 = 1 to the code after the OPTION = 7 or change OPTION = 7 to OPTION = 135 which should be 0b10000111?
    Certainly. The best thing to do would be to use

    Code:
    OPTION = 0b10000111;
    
    That will do the right thing and documents what you are doing much better than OPTION = 135;

    I would also look through the source code to see if there are any other places where you modify OPTION.

    Mike

  4. #34
    Nayth Newbie
    Join Date
    Apr 2009
    Posts
    21

    Default

    Nice, thanks for the help.

    Works perfect now that I set it to 0b10000111 in my delay rutine.

    Thanks again all

+ Reply to Thread
Page 3 of 3
First 1 2 3

Similar Threads

  1. CC5X, PIC16F631 and Interrupt
    By Nayth in forum Micro Controllers
    Replies: 4
    Latest: 17th April 2009, 09:27 PM
  2. PC Serial Port to Parallel Port Converter
    By pacobenito in forum Micro Controllers
    Replies: 6
    Latest: 18th October 2008, 02:53 PM
  3. Operate a relay from a PC port RS232 or Parallel port
    By Eddie ESV in forum Electronic Projects Design/Ideas/Reviews
    Replies: 2
    Latest: 12th June 2004, 07:43 AM
  4. [ann] COM Port Toolkit - serial port monitoring on Win32 PCs
    By MGolikov in forum Electronic Projects Design/Ideas/Reviews
    Replies: 0
    Latest: 6th April 2004, 06:17 AM
  5. Designing a circuit to convert game port to serial port
    By Diluka Moratuwage in forum General Electronics Chat
    Replies: 1
    Latest: 29th July 2003, 04:40 PM

Tags for this Thread