Low Voltage Detection


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Location
    CA
    Posts
    78

    Default Low Voltage Detection

    Hi everyone, I was having a few problem with the low voltage detection mechanism and not sure if it is my software which is causing the problem or if it is the hardware. I just want to make sure that my chip has not gone bad. I am using the pic18f6720 as the pic of choice and it has the LOW VOLTAGE DETECTION feature in this chip. here is what I have in my code. please let me know if I am doing something wrong.

    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''
    'here is what the datasheet says to do :
    1: Write the value to the LVDL3:LVDL0 bits (LVDCON registers) which selects the trip voltage.

    2:Ensure the LVD interrupts are disabled (the LVDIE bit is cleared or the GIE bit is cleared

    3: enable the LVD module (set the LVDEN bit in the LVDCON register

    4: Wait for the LVD module to stablize (the IRVST bit to become set

    5: Clear the LVD interrupt flag, which may have falsely become set, until the LVD module has stabilize (clear the LVDIF bit)

    6: Enable the LVD interrupt (Set the LVDIE and the GIE bits)

    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''

    here is what I have done

    'since I want the trip voltage to be as high as possible to allow enough time for the processor to save all the necessary values of the variable in use, I have selected the trip voltage to be V = 4.64V.

    LVDCON = %00111110 'STEPS 1 through 4 is satisfied

    'clearing the LVDIF flag which may have falsely become set.
    LDVIF = 0
    LVDIE = 1

    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''

    my question is I am not sure if simply saying LVDIF = 0 and LVDIE = 1 will clear the flag and set the interrupt for the Low Voltage Detect module. Or do I really need to WRITE directly to the PIR2 and PIE2 registers. Please correct me if I am confused. thanks in advace for anyone offering to help.

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


    Did you find this post helpful? Yes | No

    Default

    Steps 1-4 are not satisfied by this;

    > LVDCON = %00111110 'STEPS 1 through 4 is satisfied

    LVDCON = %00001110 ' Set LVDL3:LVDL0 bits for 4.64V trip
    LVDIE = 0 ' LVD interrupt disabled
    LVDEN = 1 ' Enable LVD module

    WHILE IRVST = 0
    WEND ' Wait for stable Vref

    ' Steps 1-4 done above. Steps 5-6 are below.

    LVDIF = 0 ' Clear int LVD flag
    LVDIE = 1 ' Enable LVD int
    GIE = 1 ' Enable global ints

    I would make sure my voltage levels were stable & above my LVD trip point first.

    > I am not sure if simply saying LVDIF = 0 and LVDIE = 1 will clear > the flag and set the interrupt or do I really need to WRITE
    > directly to the PIR2 and PIE2 registers

    If you have LVDIF & LVDIE defined as PIR2.2 & PIE2.2 something like this;

    SYMBOL LVDIE = PIE2.2
    SYMBOL LVDIF = PIR2.2

    then yes, you can write to them like this;

    LVDIF = 0
    LVDIE = 1

    In this case, you are writing directly to LVDIF & LVDIE in the PIR2 and PIE2 registers.

    Internal registers & bits within these registers, are defined in device specific header files. For the PIC18F6720, these should be in a file named P18F6720.INC in your MPLAB directory.

    It looks something like this;

    LVDCON EQU H'0FD2' ; Register address
    IRVST EQU H'0005' ; Bit #5
    LVDEN EQU H'0004' ; Bit #4, etc,,,

    Using assembler, you could set/clear bits like this

    @ BSF LVDCON, LVDEN
    @ BCF LVDCON, LVDEN

    With PBP, you need tell it where LVDEN is located in register LVDCON. Something like this;

    SYMBOL LVDEN = LVDCON.4

    Now you can use LVDEN = 0, etc,,,

    Note: Remember your Brown-Out reset config fuse settings too. If you have brown-out reset enabled, and it's set higher than what you set your trip point for with LVD, you might not get what you're expecting.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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. Help with final project
    By OvERKiLL in forum General
    Replies: 4
    Last Post: - 15th December 2006, 20:35
  3. Problems with RC2 and RC3
    By Christopher4187 in forum General
    Replies: 11
    Last Post: - 29th May 2006, 17:19
  4. Low Voltage Detection - 16F628A
    By charudatt in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th April 2006, 05:28
  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 : 1

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