CCS :: View topic - Low Voltage Detect interrupt
FAQ
Forum Help Profile
Official CCS Support
http://www.ccsinfo.com/forum/viewtopic.php?t=24577
Search
Log in to check your private messages
Register Log in
Low Voltage Detect interrupt CCS Forum Index -> General CCS C Discussion View previous topic :: View next topic Author RobS
Message Low Voltage Detect interrupt Posted: Wed Sep 28, 2005 4:52 pm
Joined: 29 Jan 2005 Posts: 10
I'm using the PIC18LF870/18LF8722. CCS Ver 3.23. I want to use #int_lowvolt interrupt to write to internal EE when VDD falls below a certain value. Do any fuses need to be set? What is a good way to set the LVDCON register bits? thanks
PCM programmer
Joined: 06 Sep 2003 Posts: 6775
Posted: Thu Sep 29, 2005 3:53 pm
Here is a Low Voltage Detect test program for the 18F452. If you use a variable DC power supply which is initially set at 5.0v, and you slowly reduce the voltage to 4.60v, at that point you will get this displayed: Quote: Low voltage Low voltage Low voltage Low voltage Low voltage
When you adjust the voltage above 4.60v, the messages will stop. Initially, I had some code to print "AAAAA" to let me know it was running, but I didn't need that in the final version, so it's commented out. Also note that for your PIC, you have the ability to trigger on "above" or "below" the LVD voltage. An extra parameter may be used to select this in the setup_low_voltage() function. See notes in code, below. Code: #include <18F452.h> #fuses XT,NOWDT,PUT, BORV27,NOLVP #use delay(clock=4000000) #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS) #byte LVDCON = 0xFD2 #bit IRVST_BIT = LVDCON.5 #byte PIR2 = 0xFA1
1 от 3
01.3.2007 г. 09:53
CCS :: View topic - Low Voltage Detect interrupt
http://www.ccsinfo.com/forum/viewtopic.php?t=24577
#bit LVDIF_BIT = PIR2.2 int8 lvd_flag; #int_lowvolt void lvd_isr(void) { lvd_flag = TRUE; disable_interrupts(INT_LOWVOLT); } int8 wait_for_lvd_to_stabilize(void) { int16 timeout_count; timeout_count = 0xFFFF; // Many milliseconds while(timeout_count--) { if(IRVST_BIT) return(TRUE); } return(FALSE); } //==================================== void main(void) { printf("Start\n\r"); setup_low_volt_detect(LVD_46); //setup_low_volt_detect(LVD_46 | LVD_TRIGGER_BELOW); //For 18F8722 if(wait_for_lvd_to_stabilize() == FALSE) { printf("Low Voltage Detect module didn't stabilize\n\r"); while(1); // Wait here forever } LVDIF_BIT = 0; // Clear the LVD interrupt flag enable_interrupts(INT_LOWVOLT); enable_interrupts(GLOBAL); while(1) { if(lvd_flag == TRUE) { printf("\n\rLow voltage\n\r"); lvd_flag = FALSE; LVDIF_BIT = 0; // Clear the LVD interrupt flag enable_interrupts(INT_LOWVOLT); } // delay_ms(500); // printf("A"); } } Douglas Kennedy
Joined: 07 Sep 2003 Posts: 366 Location: Florida
PCM programmer
Joined: 06 Sep 2003 Posts: 6775
2 от 3
Posted: Fri Sep 30, 2005 10:15 am
Is setup_low_volt_detect ( ) a built in CCS function?
Posted: Fri Sep 30, 2005 10:27 am
Yes, it's in the current manual.
01.3.2007 г. 09:53
CCS :: View topic - Low Voltage Detect interrupt
http://www.ccsinfo.com/forum/viewtopic.php?t=24577
Display posts from previous: All Posts
Oldest First
CCS Forum Index -> General CCS C Discussion
Go All times are GMT - 6 Hours
Page 1 of 1 Jump to: General CCS C Discussion You can post new topics You can reply to topics You cannot edit your posts You cannot delete your posts You cannot vote in polls
Go in in in in in
this this this this this
forum forum forum forum forum
Powered by phpBB © 2001, 2005 phpBB Group
3 от 3
01.3.2007 г. 09:53