delay calculation methods for 8051 and spi protocol

Thread Starter

santu

Joined Dec 23, 2010
15
hello, i am using at89s8252,a crystal of 12mhz, so please give sufficient information how can i calculate delay of any time . also please give details about the spi protocol .can u give me links where i can get information regarding spi protocol. hoping u will help me as always.thank u
 

spinnaker

Joined Oct 29, 2009
7,830
Maybe you should try a search just like anyone else would do?

As far as delays, this is done at least a couple of ways. It can be done with a timer (usually for 8051) or it can be done with instructions. Depending on the processor and the clock speed an assembler instruction takes X instruction cycles. For example on a PIC, a NOP takes one instruction cycle . One instruction cycles takes 4 osc periods. So on a PIC with a 20MHZ clock a NOP would take 0.2u seconds. You can put a few of them together or do a loop. But each instruction may take a different number of instruction cycles.

I do not know the 8051. You will need to consult the datasheet but basically this is how it is done. Your compiler might have a delay function in C, BASIC or whatever you are using. You will need to consult the compiler's documentation.

You can do a simple delay with a for loop but the results may not be accurate. If you upgrade the compiler and the optimization changes and you compile your code again, the delay may not be what it was before.
 
Top