User manual
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
457
Soft_SPI_Init
Prototype
sub procedure Soft_SPI_Init()
Description Routine initializes the software SPI module.
Parameters None.
Returns Nothing.
Requires Global variables:
- SoftSpi_SDI: Data in line
- SoftSpi_SDO: Data out line
- SoftSpi_CLK: Data clock line
- SoftSpi_SDI_Direction: Direction of the Data in pin
- SoftSpi_SDO_Direction: Direction of the Data out pin
- SoftSpi_CLK_Direction: Direction of the Data clock pin
must be dened before using this function.
Example
‘ DAC module connections
dim SoftSpi_CLK as sbit at LATF6_bit
dim SoftSpi_SDI as sbit at RF2_bit
dim SoftSpi_SDO as sbit at LATF3_bit
dim SoftSpi_CLK_Direction as sbit at TRISF6_bit
dim SoftSpi_SDI_Direction as sbit at TRISF2_bit
dim SoftSpi_SDO_Direction as sbit at TRISF3_bit
‘ End DAC module connections
...
Soft_SPI_Init() ‘ Init Soft_SPI
Notes None.
Soft_SPI_Read
Prototype
sub function Soft_SPI_Read(dim data_ as byte) as byte
Description This routine performs 3 operations simultaneously. It provides clock for the Software SPI bus, reads
a byte and sends a byte.
Parameters - sdata: data to be sent.
Returns Byte received via the SPI bus.
Requires Soft SPI must be initialized before using this function. See Soft_SPI_Init routine.
Example
dim data_read, data_send as byte
...
‘ Read a byte and assign it to data_read variable
‘ (data_send byte will be sent via SPI during the Read operation)
data_read = Soft_SPI_Read(data_send)
Notes None