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.
Bookmarks