CONFIG SPI

Top  Previous  Next

Action

Configures the SPI related statements.

 

 

Syntax

CONFIG  SPI = SOFT, DIN = PIN, DOUT = PIN , CS = PIN, CLK = PIN ,DATA ORDER  = DO, NOCS =

CONFIG  SPI = ON

CONFIG  SPI = OFF

CONFIG  SPI = HARD, INTERRUPT = ON|OFF, DATA ORDER = LSB|MSB, MASTER=YES|NO,POLARITY=HIGH|LOW,PHASE=0|1,CLOCKRATE=4|16|64|128

 

 

Remarks

When you use the software SPI mode you must specify the following information:

DIN

Data input. Pin is the pin number to use such as p1.0

DOUT

Data output. Pin is the pin number to use such as p1.1

CS

Chip select. Pin is the pin number to use such as p1.2

CLK

Clock. Pin is the pin number to use such as p1.3

NOCS

Option without parameter. Use it to disable the resetting and setting of the CS pin.

DATA ORDER

Use MSB or LSB. With MSB, MS bit will be sent first. LSB option will send the LS bit first.

SPIOUTEDGE

Falling or Rising. Falling is the default. The edge specifies if the the data will be clocked with a low to high or a high to low edge.

 

When the NOCS option is used you must reset and set the CS pin yourself.

The option is intended when you want to do large transfers between the micro and the SPI device. With the little internal memory you can do that in steps but of course you don't want the CS pin to change after each use of the SPIIN or SPIOUT routine.

 

When you want to use the hardware SPI that is available in the 89S8252, you must specify the following information:

INTERRUPT

ON or OFF to enable or disable that the SPI interrupt is set.

DATA ORDER

LSB or MSB. Determines which bit is sent first.

MASTER

Yes or No. Set it to Yes for usage with the BASCOM SPI routines.

POLARITY

High or Low. See the Atmel datasheet

PHASE

0 or 1.

CLOCKRATE

4, 16, 64 or 128. This is a division that determines the clock rate. The oscillator clock is divided by the number you specify.

ON

You can turn on/enable SPI by using this option. It sets the enable bit.

OFF

You an turn off the SPI by using this option. It resets the enable bit.

 

 

See also

SPIIN SPIOUT

 

 

Example

Config SPI = SOFT, DIN = P1.0 , DOUT = P1.1, CS = P1.2, CLK = P1.3

SPIINIT init pins

SPIOUT var , 1        'send 1 byte