Professional Documents
Culture Documents
t=24577
Author Message
Joined: 29 Jan 2005 I'm using the PIC18LF870/18LF8722. CCS Ver 3.23. I want to use #int_lowvolt interrupt to write
Posts: 10
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
Low voltage
Low voltage
Low voltage
Low voltage
Low voltage
When you adjust the voltage above 4.60v, the messages will stop.
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)
1 от 3 01.3.2007 г. 09:53
CCS :: View topic - Low Voltage Detect interrupt http://www.ccsinfo.com/forum/viewtopic.php?t=24577
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;
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
}
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");
}
2 от 3 01.3.2007 г. 09:53
CCS :: View topic - Low Voltage Detect interrupt http://www.ccsinfo.com/forum/viewtopic.php?t=24577
Page 1 of 1
3 от 3 01.3.2007 г. 09:53