User manual
457
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Soft_SPI_Write
Prototype
procedure Soft_SPI_Write(sdata : byte);
Description This routine sends one byte via the Software SPI bus.
Parameters - sdata: data to be sent.
Returns Nothing.
Requires Soft SPI must be initialized before using this function. See Soft_SPI_Init.
Example
// Write a byte to the Soft SPI bus
Soft_SPI_Write(0xAA);
Notes None
Library Example
This code demonstrates using library routines for Soft_SPI communication. Also, this example demonstrates working
with max7219. Eight 7 segment displays are connected to MAX7219. MAX7219 is connected to SDO, SDI, SCK pins
are connected accordingly.
Copy Code To Clipboard
program Soft_SPI;
// DAC module connections
var Chip_Select : sbit at LATF0_bit;
SoftSpi_CLK : sbit at LATF6_bit;
SoftSpi_SDI : sbit at RF2_bit;
SoftSpi_SDO : sbit at LATF3_bit;
var Chip_Select_Direction : sbit at TRISF0_bit;
SoftSpi_CLK_Direction : sbit at TRISF6_bit;
SoftSpi_SDI_Direction : sbit at TRISF2_bit;
SoftSpi_SDO_Direction : sbit at TRISF3_bit;
// End DAC module connections
var value : word;
procedure InitMain();
begin
TRISB0_bit := 1; // Set RB0 pin as input
TRISB1_bit := 1; // Set RB1 pin as input
Chip_Select := 1; // Deselect DAC
Chip_Select_Direction := 0; // Set CS# pin as Output
Soft_Spi_Init(); // Initialize Soft_SPI
end;
// DAC increments (0..4095) --> output voltage (0..Vref)
procedure DAC_Output( valueDAC : word);
var temp : byte; volatile;