Srigopal007
- 5th January 2005, 16:52
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.
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''
'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.