Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Hans Marée
01/25/10 10:29
Read: 414 times
Tilburg
Netherlands


 
#172710 - execution speed and crystal frequency
Hi, I just started out with microcontrolers and have a question about the execution speed in combination with the crystal used as clock.

I made a test program which simply decrements P0 in a loop (with some delay). It all works fine, I've got 8 LED's connected to P0 so I have a simple binairy counter.
Now for my question: I have two different crystal oscillators, one with a frequency of 11.059 MHz and on of 32.768 MHz. I read the 8051 tutorial from the site and I understand that with the 32 MHz one my program should run almost 3x as fast as the 11 Mhz one, right?

Except it doesn't... When I change the crystal the LED's blink just as fast. I timed it with the stopwatch on my phone and it takes (independent of the crystal) about 6 seconds to count from 0 all the way to 255 where it wraps back to 0.

The microcontroler I use is an AT89S51RC. As far as I can tell from the data-sheet it has no internal timer and can be used with a crystal between 0 and 33MHz.
I connected the crystal between pins XTAL1 and XTAL2 and connected connected both pins to the ground using 30pF capacitors as instructed in the data-sheet.

The program I run is:

	ORG	0h

START:
	MOV	P0, #255
LOOP:
	CALL	DELAY
	DEC	P0
	SJMP	LOOP
	

DELAY:
	MOV	R1, #100
DELAY1:
	MOV	R2, #100
DELAY2:
	DJNZ	R2, DELAY2
	DJNZ	R1, DELAY1

	RET

END

 


I'm probably missing something really obvious here, but can't figure out what. Can anyone explain why my program runs at the same speed with a different crystal.

Thanks,
Hans

List of 26 messages in thread
TopicAuthorDate
execution speed and crystal frequency      Hans Marée      01/25/10 10:29      
   my guess is ...      Erik Malund      01/25/10 11:26      
   overtone      Stefan KAnev      01/25/10 11:27      
   As others already mentioned...      Kai Klaas      01/25/10 13:16      
      Indeed overtone      Hans Marée      01/26/10 13:48      
         Just try the crystal with 15pF + 15pF caps.      David Prentice      01/26/10 14:26      
   Try it with a crystal oscillator, rather than a crystal      Richard Erlacher      01/25/10 16:42      
      baloney      Erik Malund      01/25/10 16:51      
         Baloney #2      Andy Neil      01/25/10 18:02      
         Where is your head wedged, Erik?      Richard Erlacher      01/25/10 18:38      
            just correcting invalid info      Erik Malund      01/25/10 19:00      
               SO ... What, exactly, is incorrect?      Richard Erlacher      01/25/10 23:35      
                  already stated      Erik Malund      01/26/10 07:33      
                     You are showing us how smart you are again, Erik!      Richard Erlacher      01/26/10 09:28      
                        not my intention, but thanks for the compliment      Erik Malund      01/26/10 09:46      
         Richard is right...      Kai Klaas      01/26/10 10:12      
            I do not use these and ....      Erik Malund      01/26/10 10:19      
               Fact is ...      Richard Erlacher      01/26/10 18:49      
                  as Kai stated      Erik Malund      01/26/10 19:19      
                     so ... Erik ... what's your point?      Richard Erlacher      01/26/10 21:25      
                        I did      Erik Malund      01/27/10 05:32      
                           Once again, Erik, you've missed the point      Richard Erlacher      01/27/10 09:58      
                              YOU would sell a suicide candidate a rope      Erik Malund      01/27/10 11:15      
                                 come on...      Stefan KAnev      01/27/10 12:08      
                     come on...      Stefan KAnev      01/27/10 12:07      
   Specifying Quartz Crystals      Enrique Viseras-Marin      01/26/10 06:35      

Back to Subject List