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 support@ccsinfo.com

Time delay between power up and main function [Solved]

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



Joined: 13 Sep 2013
Posts: 3

View user's profile Send private message

Time delay between power up and main function [Solved]
PostPosted: Tue Sep 17, 2013 5:46 am     Reply with quote

Hello my friends,

I have PIC18F8723 micro controller in my circuit, this MCU controls inhibit of main power supply. When MCU power supply is stand up, I could not control any ports earlier than 63msec. Minimum time delay of controlling a port in main function is 63msec as shown. In scope screen yellow signal is pin of MCU, green signal is MCU power supply.



How can i control any ports just after power up?I want to shorten this delay as soon as possible.

Fuses:
Code:
#FUSES NOWDT                    //No Watch Dog Timer
//#FUSES HS                     //Low power osc < 200 khz
#FUSES INTRC_IO                 //Internal Oscillator enabled  LEBC
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT
//!#FUSES BROWNOUT                 //brownout reset enabled    LEBC
//!#FUSES BORV42                   // 4.2'de reset olacak
#FUSES NOPUT                    //Power Up Timer enabled
#FUSES NOCPD                    //No EE protection
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOCPB                    //No Boot Block code protection
#FUSES MCLR                   //Master Clear pin enabled


Main function summary:
Code:
void main()
{

   set_tris_E(0x00);
   output_E(0x80);
...
}



I fixed it

#zero_ram statement had been coused this delay. I remove this statement. Now i can control ports as soon as power comes.



Thanks.


Last edited by ZuLu on Thu Sep 19, 2013 2:43 am; edited 1 time in total
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Sep 17, 2013 7:23 am     Reply with quote

since all I/O on the pic wakes up as tri state - you need to add a pull up or pull down resistor to the critical control pins until your program is ready to assert control. This is PIC safety 101 Very Happy Very Happy Very Happy

also for best practice, set the desired initial state of the control pin BEFORE the set_tris operation.........
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Tue Sep 17, 2013 8:17 am     Reply with quote

So true asmboy, got bitten nicely by not setting the output before setting the tris, everything went up in smoke about 2 times before I figured that one out.

Regards
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Tue Sep 17, 2013 10:31 am     Reply with quote

Also many PICs start up on an internal clock source and run some initialisation code before the main clock source is stable. That means it won't run at the expected speed during start-up, often running slower for some considerable time, making delays much longer than expected.

I got caught by this on a PIC18F4580 and had to detect the change from slow internal to the faster PLL-multiplied main clock source:

Code:

// Wait for the crystal to stabilise. Before it does, we're on the default
// 1MHz internal clock which confuses the start-up timing.
// This is not needed and is just here to ensure we get normal timing from start-up.
while ((setup_oscillator() & OSC_STATE_STABLE) == 0);


Something like this might well be needed for other PICs. It won't speed up the start-up. It just waits for the main clock to kick in to ensure delays and baud rates are as expected.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 17, 2013 1:39 pm     Reply with quote

Quote:
time delay of controlling a port in main function is 63msec as shown.

The 18F8723 data sheet shows a power-up delay of 64 ms for the
internal oscillator (INTRC_IO), if you have the PUT fuse enabled.
But you have NOPUT. Or do you ?

You should your complete current test program, not snippets of it.

Post the #include line for the PIC. Post the #use delay() statement.
Post a small compilable program.

And post your full CCS version number, which will be in this format: x.xxx
Examples of version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
ZuLu



Joined: 13 Sep 2013
Posts: 3

View user's profile Send private message

PostPosted: Wed Sep 18, 2013 4:36 am     Reply with quote

I finally successed to control any port just after power up.

"#zero ram" statement had been caused that delay. I remove #zero ram preprocessor statement and now i can control ports as soon as MCU power stands up.
Ttelmah



Joined: 11 Mar 2010
Posts: 19401

View user's profile Send private message

PostPosted: Wed Sep 18, 2013 4:51 am     Reply with quote

It is worth realise just how much 'work' #zero_ram involves. On this chip, nearly 4000 RAM locations have to be cleared.....
No wonder it took a long time.

Goes back to always post a small _complete_ program that shows the problem. You left this directive out in what you posted, and every experienced user here would instantly have said 'several thousand instructions here'....

Best Wishes
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