04.03.2013 Views

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Speeds<br />

Processor Mode 0-4 Mode 5-7<br />

BA 50 Kbps 100 Kbps<br />

BAN 20 Kbps 40 Kbps<br />

BAP 100 Kbps 380 Kbps<br />

BAP40 400 Kbps 400 Kbps<br />

ARC32 400 Kbps 400 Kbps<br />

Commands<br />

All SPI devices fall into 4 main transmission modes. They are specifi c to the timings of the writing and<br />

reading of data. The write and read of data at the fi rst edge of the clock pulse is PRE. The second<br />

edge of the clock pulse is POST. The PRE and POST edge of the clock will change depending on<br />

whether the clock starts high(1) or low(0).<br />

Most SPI device data sheets will indicate if they are PRE, POST, MSB or LSB. However in some<br />

cases the data sheet might not be clear. So fi rst, we must determine if the data is read PRE or POST<br />

clock edge. In almost all cases data can be written and read on the rising and falling edge of the<br />

clock signal. Looking at the timing diagrams below the clock can start from one of two states high(1)<br />

or low(0). The diagrams below illustrate the PRE and POST edge based on a high(1) or low(0) clock<br />

start.<br />

High(1) Clock Start<br />

CLOCK<br />

Low(0) Clock Start<br />

PRE Edge<br />

POST Edge<br />

1 2 3 4 5 6 7 8<br />

DATA D7 D6 D5 D4 D3 D2 D1 D0<br />

CLOCK<br />

DATA<br />

PRE Edge<br />

POST Edge<br />

1 2 3 4 5 6 7 8<br />

D7 D6 D5 D4 D3 D2 D1 D0<br />

The diagrams for clock start show the data in both cases being written on the POST edge of the<br />

clock. The next thing to determine is the bit order. Which from the diagram, starts with bit 7 (D7) and<br />

ends with bit 0 (D0), this is MSB (Most Signifi cant Bit First). If the byte order were reversed and bit 0<br />

(D0) was fi rst with bit 7 (D7) last that would be LSB (Least Signifi cant Bit First)<br />

192

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!