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

PIC18F452 @ 20MHz slowdown by LED.

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



Joined: 14 Aug 2012
Posts: 16

View user's profile Send private message

PIC18F452 @ 20MHz slowdown by LED.
PostPosted: Tue Oct 30, 2012 2:34 pm     Reply with quote

Hi,

I have a PIC18F452 with 20MHz crystal behaving strange.
When I insert the lines :

Code:

output_low(PIN_D7);
delay_ms(1500);
output_high(PIN_D7);
delay_ms(100);


The PIC seems to be slow and the text on the LCD display is changing slowly (like when a LCD is working at low temperature). The LED is blinking OK.
When those lines are greyed out, everything is fine, and the display is reactive.
Compiler 4.120

Cheers.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Oct 30, 2012 2:40 pm     Reply with quote

You're adding a 1.6 second delay into your system.

Why are you surprised that everything seems to be so tardy?

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9162
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Oct 30, 2012 2:42 pm     Reply with quote

Every delay_ms(xxx),delay_us(xxx),etc. the PIC will 'twiddle it's thumbs' and do NOTHING except loop around and around, counting down until the total time expires for the 'delay'.
NOTHING else can happen until the PIC exits the delay routine...

If you printout the listing and read the delay_aa(xxx) code, you'll see why.

If you want the PIC to do anything else while a 'delay' is in progress, you need to run timers and interrupts to achieve 'multitasking'.

hth
jay
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