Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

microcontroller system clock related to SPI clock source

Status
Not open for further replies.

ejleiss

Junior Member level 2
Junior Member level 2
Joined
Jul 2, 2009
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,446
Hello,

Is there a rule of thumb for microcontroller system clock speed, when using SPI? For example, I am using a SPI to communicate with a sensor where in the sensors datasheet it says to use an SPI clock speed of no less than 2MHZ. My question is, how is my microcontroller system clock speed related to the SPI clock? Does it have to be a certain many times greater than the SPI clock?

Thanks
 

It depends on the microcontroller. But for the PIC microcontrollers I am familiar with, the SPI clock is generated from the system clock through a configurable divider. It is configurable so that you can make the design tradeoffs of throughput vs. speed limitations of connected devices. Since your device specifies a minimum SPI speed, I'll guess it is an A/D converter that uses the SPI clock to pace the successive approximations sequencing, and that the minimum speed specification is to avoid sampling capacitor droop during the conversion process.
 

The SPI clock is generated from the microcontroller clock and should be programmable to adapt to the different peripherals. The peripherals usually have a maximum SPI clock speed specified. If it has a minimum defined as well the internal logic might be dynamic or there is an internal time limit for the data exchange. In fast microcontrollers the internal clock speed is much higher than the SPI clock.

Enjoy your design work!
 

I guess my real question is.. I am running my microcontroller clock with the 32MHZ inernal RC, my SPI device would ideally like to have a clock speed of 2MHZ. Is there a limit to how low I can set my micro clock (to save power) without screwing up my SPI device?

Thanks
 

Look at the two requirements:

1. you must not exceed the maximum SPI clock speed for the peripheal.
2. You must have sufficient processing speed to load/unload the data from the SPI interface.

Normally the SPI clock is generated by a dedicated module in the microcontroller and there would be a method of dividing the system clock until it is low enough to meet your SPI clock requirement. You can set the SPI speed by picking an appropriate division ratio in the SPI clock generator.

If you are generating SPI by 'bit-banging', in other words entirely in software, you can set the SPI speed by adding software delays but obviously to do that the time taken per instruction (based on system clock) must be short enough to handle the extra instruction overhead.

Whichever method you use, the processor clock has to run faster than the SPI clock and probably by a fact of ten times or more. Exactly how much faster depends on how long it takes to process the SPI data and nobody can tell you that without detailed information on your software and instruction timing.

Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top