CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

how to check the BOR bit

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
karthickiw



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

how to check the BOR bit
PostPosted: Tue Sep 18, 2007 9:47 am     Reply with quote

sir,

i write the program for write the data in eeprom during power fail time. I check the BOR bit and write the data into the memory but program is store the data during the power on time itself....

program is

Code:

#include<16f873a.h>
#device adc=10
#use delay (clock=4000000)
#fuses xt,nowdt,noprotect,noput,nolvp,BROWNOUT
#use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8)


#BYTE PCON_REG=0x8E                //  BOR address
#BIT BOD_BAR=PCON_REG.0
#BIT POR_BAR=PCON_REG.1




void main()
{
int value;

setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports( ALL_ANALOG );
set_adc_channel(1);

while (true) {

 delay_ms(200);
   value = read_adc();
   printf("\f A/D value = %U bor= %u POR= %u", value, BOD_BAR,POR_BAR);

   if (BOD_BAR)  //check the BOR bit
   {
                     
   }
   else
   {
    write_eeprom(0,2) ;  //  power fail time, this line is executed
   }

}

}
[/code]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 18, 2007 10:53 am     Reply with quote

It's useless to read the BOR bit, because if Brownout is enabled the PIC
will reset when it hits the BOR voltage. You need a method to
detect the low Vdd voltage, and still allow the main program to keep
running.

If you want to detect the low Vdd voltage internally in the PIC, then
get a PIC that has a LVD module (Low Voltage Detection), such as
the 18F452 or other PICs. Here's some example code to use LVD:
http://www.ccsinfo.com/forum/viewtopic.php?t=24577
You also need the PCH compiler (or PCWH) to compile code for the 18F PICs.
karthick.E
Guest







thank u
PostPosted: Tue Sep 18, 2007 8:09 pm     Reply with quote

sir,

pls give any idea to write the process data during power fail time sir... i try RB0 pin interrupt, but RB0 only goes interrupt function voltage is low to high... how detect the high to low interrupts in RB0 of PIC16F873A.. pls give any circuit diagram sir...
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Sep 19, 2007 2:22 am     Reply with quote

Quote:
RB0 only goes interrupt function voltage is low to high...
Use the function ext_int_edge() to select the edge that should generate the interrupt.

Detecting power supply problems using the interrupt pins is not easy because the trigger level is related to the power supply. So when the supply voltage drops, so does the trigger level and you will never see an interrupt. A way to work around this limitation is when you connect the interrupt pin to a voltage divider that is placed before the voltage regulator of your application.

The PIC16F873A is not the best chip for detecting power supply problems because it has no Low Voltage Detect (LVD) module. Why are you using this chip? For example the PIC16F913 also has 28 pins, has more features including an LVD module, uses less power and is cheaper.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group