Electronic – Determine suitable clock speed

clock-speedpicsound

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?

Best Answer

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.