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

Question/Trouble in using #fuses

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



Joined: 03 Mar 2004
Posts: 11

View user's profile Send private message

Question/Trouble in using #fuses
PostPosted: Mon Oct 04, 2004 12:15 pm     Reply with quote

I am using 18F8620 in my design, and my application requires Brownout detect with Brown out voltage at 4.2V.

1) When I use #fuses to set up BROWNOUT as:

#include <18F8620.h>
#fuses HS,NOWDT,PUT, NOPROTECT, NOLVP, BROWNOUT

I notice the HEX file generated by CCS still has no BROWNOUT flag:

:020000040030CA
:0E00000000220C0E83030100FFC0FFE0FF4052

2) How do I specify Brown out voltage 4.2V?

3) When brownout is detected, will the PiC simply reset? If not, what will it be?

Thanks for your attention/time!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 04, 2004 12:31 pm     Reply with quote

What compiler version are you using ? I compiled this test program
using your fuse settings with PCH vs. 3.188, and it worked OK.
See the results for Config word 2, below:

Code:
#include <18F8620.H>
#fuses HS,NOWDT,PUT, NOPROTECT, NOLVP, BROWNOUT

main()
{
while(1);
}


From the .HEX file:
Code:
:0E00000000220E0E83038100FFC0FFE0FF40D0


From the end of the .LST file:
Code:
Configuration Fuses:
   Word  1: 2200   HS NOOSCSEN
   Word  2: 0E0E   BROWNOUT WDT128 NOWDT BORV25 PUT
   Word  3: 0383   NOWAIT MCU CCP2C1 T1STANDARD
   Word  4: 0081   STVREN NODEBUG NOLVP
   Word  5: C0FF   NOPROTECT NOCPD NOCPB
   Word  6: E0FF   NOWRT NOWRTD NOWRTC NOWRTB
   Word  7: 40FF   NOEBTR NOEBTRB
chen



Joined: 03 Mar 2004
Posts: 11

View user's profile Send private message

PostPosted: Mon Oct 04, 2004 12:52 pm     Reply with quote

I am using Picc 3.186

BTW:

How do I specify 4.2V brownout voltage?

How do I detect a brownout from the software? (Checking RCON register?)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 04, 2004 1:29 pm     Reply with quote

Quote:
How do I specify 4.2V brownout voltage?

To see the list of parameters for the #fuse statement, look at
the start of the 18F8620.H file. This file is in this folder:
c:\Program Files\Picc\Devices
You will see several available settings in this format: BORVxx

Quote:
How do I detect a brownout from the software? (Checking RCON register?)

You could read the RCON register directly (after defining the address
with a #byte statement), or you could use the restart_cause() function.
The values that it returns are also given in the 18F8620.H file.
chen



Joined: 03 Mar 2004
Posts: 11

View user's profile Send private message

PostPosted: Mon Oct 04, 2004 2:15 pm     Reply with quote

Thanks for your quick reply.

I tried BROWNOUT, and it simply doesn't work at all with CCS 3.186, but BORV42 works fine.

I will try some later version of CCS to see if it works there
chen



Joined: 03 Mar 2004
Posts: 11

View user's profile Send private message

PostPosted: Tue Oct 05, 2004 7:30 am     Reply with quote

I just tried CCS 2.212, and the fuses were set correctly.

Now, a new question:

When I gradually lower the power supply voltage from 5 all the way down, until the PIC quits, I don't see the BrownOut reset, which is set at 4.2V

I also tried to lower it to 3.5V then back to 4.5V, I still don't see brownout reset

How is it supposed to work?

Thanks again!
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Oct 05, 2004 8:53 am     Reply with quote

don't know it your hardware is buit yet or if you have pins available,...but
you could read analog volt from A pin on PIC and tie a output pin with a pull-up res to your reset. I know its not pretty, but it may work for you.


AND you could do a little more processing before the power dies.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 05, 2004 10:24 am     Reply with quote

Please check the config bits by reading the PIC with your programmer.
Make sure that the correct bits are set:
BOREN = 1

// The following setting gives 4.2v
BORV0 = 1
BORV1 = 0

Also they recommend that the Power-up Timer should be enabled
when using Brownout reset.

\PWRTEN = 0 (ie., True)

See the reference manual:
http://ww1.microchip.com/downloads/en/DeviceDoc/39503.pdf

After you've checked all these things, if it still doesn't work, I will
drag my heavy variable power supply out of the closet and test BOR
with a 18F452 or 458. But I'm asking you to check everything first.
chen



Joined: 03 Mar 2004
Posts: 11

View user's profile Send private message

PostPosted: Tue Oct 05, 2004 10:56 am     Reply with quote

Thanks, I will confirm that.

According to the 18F8620 user manual (section 3.5) and my setup, brownout reset should occur when supply is below 4.2V for more than 200us, and the chip will remain in brownout reset until Vdd rises above BVdd.

Since my Vdd drops slowly, once it is below BVdd, it will never come back above it, so it is not really a brown out here.

I wonder if there is a way for me to get a warning of Vdd is below 4.2V (without adding power monitoring circuit outside of PIC).

Anyway, I don't think it is CCS' problem, for the HEX file does have the correct flags set.

Thanks again for your time!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 05, 2004 11:44 am     Reply with quote

I tested Brownout reset with the 18F458, and it works completely as
expected.

This is the test program I used:
Code:
#include <18F458.h>
#fuses XT, NOWDT, PUT, PROTECT, NOLVP, BROWNOUT, BORV42   
#use delay(clock = 4000000)   
#use rs232(baud = 9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//========================================
void main()
{
char i;

printf("Start\n\r");

i = 0;

while(1)
  {
   printf("%x\n\r", i++);
   delay_ms(500);
  }

}


First, I ran that program with the NOBROWNOUT fuse setting.
I noted that it ran OK down to 3.0 volts, or less. Then I recompiled
and programmed the PIC with the BROWNOUT and BORV42 settings.

Then I slowly turned the voltage knob down, while watching my
digital voltmeter. When it got down to about 4.3v, the program
stopped sending characters via RS-232. If I then raised the
voltage back up a little, the PIC reset itself and started outputting
characters again. Here is the output from the terminal window.
Code:
15
16
17
18
19
1a
Start
00
01
02
03
04 


Please try this program on your test board.
chen



Joined: 03 Mar 2004
Posts: 11

View user's profile Send private message

PostPosted: Tue Oct 05, 2004 12:28 pm     Reply with quote

PCM programmer & treitmey:

Thanks for your time

As I stated in my last post, I finally realized my test condition was not really a brown-out case, but a slow discharging, thus I will not see the PIC come out off the brown-out reset

I may have to use some external circuit to generate the interrupt so that I can do some final clean before the PIC dies.
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