View previous topic :: View next topic |
Author |
Message |
Rob_975
Joined: 14 Aug 2012 Posts: 16
|
PIC18F452 @ 20MHz slowdown by LED. |
Posted: Tue Oct 30, 2012 2:34 pm |
|
|
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
|
|
Posted: Tue Oct 30, 2012 2:40 pm |
|
|
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: 9255 Location: Greensville,Ontario
|
|
Posted: Tue Oct 30, 2012 2:42 pm |
|
|
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 |
|
|
|