I want to learn about good techniques on how to choose the suitable clock speed for the microcontroller for a project.

For example i want to create a device with a pic16f877 microcontroller that record voice and store it in the memory and then play it out. I don't want to process the signal in order to use a dsp. The audio will have the specs below:

  • a sampling ratio of 8Khz

  • 16-bit word length

  • stereo

So if i record 1 minute of sound then i will need 1.8 mb of storage space. The microcontroller also will connect to a DAC with an SPI serial port. My question is how i could figure out the suitable clock speed that i need. Does the DAC and the SPI protocol determine this speed or the sampling rate of the sound?

  • \$\begingroup\$ Are you talking about the clock speed for the microcontroller, the clock speed for the SPI interface, or something else? \$\endgroup\$
    – Dave Tweed
    Mar 18, 2013 at 11:46
  • \$\begingroup\$ The clock speed for the microcontroller. Sorry i didn't define it in the question. \$\endgroup\$
    – 20317
    Mar 18, 2013 at 11:51
  • \$\begingroup\$ Are you going to use a parallel ADC because then you get one parallel result at the end of a conversion and this reduces overheads in a micro. However, the ADC may need a clock operating at 16 x 8kHz to achieve the conversion. More info needed. Maybe go for the maximum clock speed that the PIC will run at - this will leave you capacity to do other things. If you went for a clock that only just did what you want then there is no room for doing other things. \$\endgroup\$
    – Andy aka
    Mar 18, 2013 at 11:53
  • 1
    \$\begingroup\$ Why sample 16-bit audio at 8kHz? That seems an odd way round to me. 8-bits sampled faster might give better quality, I'm sure google will turn up plenty of papers on sampling rates/depth etc. \$\endgroup\$
    – John U
    Mar 18, 2013 at 17:37

1 Answer 1


Unless you are power-constrained, make it as fast as possible. The 16F877 is a old part and slow compared to many newer and cheaper parts available today. Its top speed is 20 MHz clock, which results in 5 MHz instruction rate. All 18F can go at least 2x as fast, and the 24H and 33F another 4x beyond that and manipulate 16 bit quantities per instruction.

If you need to save power, then the '877 make little sense, so if you're using the '877, then maxxing it out is a no-brainer. Use a 20 MHz crystal and you're done.

  • \$\begingroup\$ But as you say if i am power-constrained and i have only the '877 device there is a formula i can use to calculate if the 4MHz for example is enough or if i need more? To find out which is the least clock speed that i could use? \$\endgroup\$
    – 20317
    Mar 18, 2013 at 12:13
  • 3
    \$\begingroup\$ @20317: If you are power constrained, then don't use the '877. Newer PICs are faster, cost less, and have more peripherals and memory. Otherwise, count SPI clocks you need to do one sample and see if you can fit them all into a sample time at the maximum clock rate. You may need to add firmware overhead time too, depending on how much you can overlap that with the SPI activity. \$\endgroup\$ Mar 18, 2013 at 14:29
  • \$\begingroup\$ A lower clock frequency implies less power consuming, right? So isn't the goal to always aim for a frequency as low as possible while still being able to perform all the instructions required for the task? \$\endgroup\$ Nov 28, 2015 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.