Instructions

341 C-Control Pro IDE
© 2013 Conrad Electronic
5.23.1.2
SPI_Enable
SPI Functions
Syntax
void SPI_Enable(byte ctrl);
Sub SPI_Enable(ctrl As Byte)
Description
The SPI interface is initialized with the value of ctrl (see SPCR register in Atmel Mega Reference Manual).
Parameter
ctrl initialization parameter (Mega SPCR Register)
Bit 7 - SPI Interrupt Enable (do not enable, cannot be used from C-Control Pro now)
Bit 6 - SPI Enable (must be set)
Bit 5 - Data Order (1 = LSB first, 0 = MSB first)
Bit 4 - Master/Slave Select (1 = Master, 0 = Slave)
Bit 3 - Clock polarity (1 = leading edge falling, 0 = leading edge rising)
Bit 2 - Clock Phase (1 = sample on trailing edge, 0 = sample on leading edge)
Bit 1
Bit 0
SCK Frequency
0
0
f
Osc
/ 4
0
1
f
Osc
/ 16
1
0
f
Osc
/ 64
1
1
f
Osc
/ 128
Please consider, that f
Osc
= 14,7456 Mhz for C-Control Pro Mega 32 and Mega128, while the C-
Control Pro Mega128 CAN works at 16 Mhz.
5.23.1.3 SPI_Read
SPI Functions
Syntax
byte SPI_Read();
Sub SPI_Read() As Byte
Description
A byte is read from the SPI interface.