Exploring STC MCU Part 2 – So how fast is it?

STC proudly claims that their MCU are fast. And from what I see in their core clock timing table they have a new core design that accelerated the instructions a lot. So how fast is it?

First off, let’s drive an I/O pin at maximum frequency.

#include <stc15f2k60s2.h>

int main(void)
  for (;;)
    P27 = !P27;

It doesn’t show up on the LED (since human eyes are not fast enough anyway) but what about the oscilloscope?

Setting the fuses

IAP15W4K61S4 have a few fuses that can be configured to control various aspects of the chip. It can be changed but only when uploading a program (not while uploading the OCD monitor though.) I uploaded the compiled program for the sake of setting the fuses, before uploading the OCD monitor.

Wiring things up

Clock measurement wiring
This is how the circuit is wired up during this experiment.

The test circuit is easy enough to set up. I had issues using the P4.5 pin as output (maybe it needed more setup code than expected?) but moving it down to P2.7 I get an output.

The code above toggles the pin at highest frequency possible, and I got 2.5MHz from a 30MHz clock. So it takes 6 cycles to execute the two instructions: toggle the pin, and loop back. Referring back to the datasheet, both instructions are 3-clock instructions.

I am running with X10 probe, so 5V signal level shows up as 0.5V.
I am running with X10 probe, so 5V signal level shows up as 0.5V.

Here is the waveform emitted in this experiment and the frequency through the frequency counter feature on my function generator. (I have wired my function generator so its external frequency counter input is drawn directly from the channel 1 front end amplifier output.) All seems good.

Next time, I will try to set up a timer for millis() and delay() functions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.