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

Monitor 12F683 Vdd and wake-up when >2Vdc

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



Joined: 23 Jun 2010
Posts: 19

View user's profile Send private message

Monitor 12F683 Vdd and wake-up when >2Vdc
PostPosted: Wed Jun 23, 2010 4:33 am     Reply with quote

I am using a PIC 12F683 and the CCS C-compiler on an MPLAB IDE.

I would like to write a program that monitors the Vdd on a 12F683 that is in sleep mode and wakes-up only when Vdd is greater than 2Vdc.

Appreciate your suggestions.
ckielstra



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

View user's profile Send private message

PostPosted: Wed Jun 23, 2010 5:15 am     Reply with quote

Read the data sheet on the brown-out feature.
The brown-out fuse will keep the chip in reset when Vdd < 2.0V
delesan



Joined: 23 Jun 2010
Posts: 19

View user's profile Send private message

Monitor 12F683 VDD and wake-up when >2Vdc
PostPosted: Wed Jun 23, 2010 6:19 am     Reply with quote

I am new to programming with the PIC12F683 and the CCS compiler.
I have gone through the 12F683 manual and also the CCS C- reference manual but its not clear. How do I set the value of VBOR and TBOR? Could you assist with example program codes in C for this? I have been using this forum as reference as I progress programming the 12F683.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Wed Jun 23, 2010 2:57 pm     Reply with quote

Are you sure you are reading the right data sheet?....
The 12F683, doesn't have any VBOR configurations. Single voltage at 2.1v.
The four possible configurations for the brownout, are:
Code:

BODEN<1:0>: Brown-out Detect Selection bits(1)
11 = BOD enabled
10 = BOD enabled during operation and disabled in Sleep
01 = BOD controlled by SBODEN bit (PCON<4>)
00 = BOD disabled

Which are setup by the four fuse options in CCS:

BROWNOUT,BROWNOUT_NOSL,BROWNOUT_SW,NOBROWNOUT

For the software controllable brownout, look at 'brownout_enable'.

Best Wishes
delesan



Joined: 23 Jun 2010
Posts: 19

View user's profile Send private message

Monitor 12F683 VDD and wake-up when >2Vdc
PostPosted: Thu Jun 24, 2010 3:00 am     Reply with quote

Thanks.

Will write a small program using Brownout enable in configurations.

Will keep you posted on my progress.

As a background, am powering the 12F683 with a periodic burst pulse rectified to dc and the 12F683 is set for an internal clock frequency of 500KHz. Its envisaged that while Vdd voltage to the chip is less than 2Vdc, the 12F683 remains in sleep mode and only awaken when Vdd is >2Vdc thereby blinking an LED.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Thu Jun 24, 2010 3:43 am     Reply with quote

You need to understand that with Vdd<2v, the chip reaches the point where there is not sufficient voltage present to maintain data correctly latched in the internal registers and memory. The minimum warranted voltage for the chips internal registers to hold data, is 2v. As such you can't put the chip to sleep, and expect to wake up again with data intact, if you go below this.

However when asleep, the chip draws a tiny amount of power. I have processors that have happily held their data, with 'standby' supply rails from a coin cell, used whenever the chip is asleep, for many years.
You have a series of choices:
1) Add an external power monitor circuit. Have this switch the processor to a battery supply, when the incoming rail falls below 2v, and trigger an interrupt to wake the processor when the supply rises above this. Put the processor to sleep when on the battery supply. Done properly, consumption of a couple of nA is possible like this.
2) Use the brownout. Have the processor code re-initialise when this it restarts.
3) Do a similar battery 'sleep' to '1', but with the processor switching the supply rails. Keep the comparator circuit awake, and have this trigger the wake-up. Downside, consumption increases to >30nA, and if you use the internal comparator Vref, well over 100nA.

The simplest, and cheapest solution, is just to use the brownout, and write the code to correctly reinitialise when power is re-applied. The most reliable/flexible solution, is '1', but this requires external components.

Best Wishes
delesan



Joined: 23 Jun 2010
Posts: 19

View user's profile Send private message

RE:Monitor 12F683 Vdd and wake-up when >2Vdc
PostPosted: Thu Jun 24, 2010 4:00 am     Reply with quote

Many thanks for the detailed explanation.

This explains why the 12F683 manual talks about 2.1V.

For my particular application, I will go for the Brownout as I am restricted and can't add further external components and have to rely on software.
You mentioned that the program must be able to re-initialize when it wakes from Brownout. Could you expantiate more? Is there any website/link I could visit for example c-codes where Brownout has been practically used? Since I am limited to a periodic supply lasting ~ 1s, I need to efficiently use it to power the 12F683 casuing it to blink an LED. The smothening capacitor in the rectifier circuit is in the hundred uF range and takes a while to charge-up. During this charge-up phase, I will like the microcontroller to remain in sleep mode.
delesan



Joined: 23 Jun 2010
Posts: 19

View user's profile Send private message

RE:Monitor 12F683 Vdd and wake-up when >2Vdc
PostPosted: Thu Jun 24, 2010 9:32 am     Reply with quote

Just checked through the 2007 12F683 data sheet. On page 87, Figure 12-3 shows that the brownout causes a positive-going rise in the internal reset when there is a dip below Vdd, lower than VBOR. It doesn't reset for an increasing Vdd.
I am interested in monitoring the Vdd on the 12F683 from start-up, as the voltage ramps-up across the charging capacitor. During the charging period, the 12F683 should be in the 'sleep' mode; only waking up when the Vdd voltage exceeds 2.1Vdc and then blink an LED.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Thu Jun 24, 2010 9:54 am     Reply with quote

If your processor is not awake, it can't go to sleep....
The point about brownout, is that it ensures a clean reset, when the voltage falls into the 'danger area'.
The brownout circuitry _holds the device in reset_, once the voltage is below Vbor, _till the voltage rises above Vbor_. It releases on the rise.
If your voltage rises slowly, you will not meet the SVdd spec (0.05V/mSec for the rise in Vdd, to guarantee a reset).
You really cannot do what you are describing, without external circuitry.

Best Wishes
delesan



Joined: 23 Jun 2010
Posts: 19

View user's profile Send private message

RE:Monitor 12F683 Vdd and wake-up when >2Vdc
PostPosted: Fri Jun 25, 2010 2:00 am     Reply with quote

Many thanks once again for the clarification.
I will now resort to setting a long delay immediately on power-up of the 12F683 - time enough for the capacitor to charge with minimal loading from the PIC- and on the elapse of the delay, blink the LED.

Thanks for your contributions and suggestions.
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