User manual
410
mikoBasic PRO for PIC32
MikroElektronika
SPI_Set_Active
Prototype
sub procedure SPI_Set_Active(dim read_ptr as ^TSpi_Rd_Ptr, dim write_ptr as
^TSpi_Wr_Ptr)
Description Sets the active SPI module which will be used by the SPIx_Read and SPIx_Write routines.
Parameters Parameters:
- read_ptr: SPI1_Read handler
- write_ptr: SPI1_Write handler
Returns Nothing.
Requires Routine is available only for MCUs with multiple SPI modules.
Used SPI module must be initialized before using this function. See the SPIx_Init and SPIx_Init_
Advanced routines.
Example
SPI_Set_Active(@SPI1_Read, @SPI1_Write) ‘ Sets the SPI1 module active
Notes Number of SPI modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.
Library Example
The code demonstrates how to use SPI library functions for communication between SPI2 module of the MCU and
MCP4921 DAC chip.
Copy Code To Clipboard
program Sound
sub procedure Tone1()
Sound_Play(659, 250) ‘ Frequency = 659Hz, duration = 250ms
end sub
sub procedure Tone2()
Sound_Play(698, 250) ‘ Frequency = 698Hz, duration = 250ms
end sub
sub procedure Tone3()
Sound_Play(784, 250) ‘ Frequency = 784Hz, duration = 250ms
end sub
sub procedure Melody() ‘ Plays the melody “Yellow house”
Tone1() Tone2() Tone3() Tone3()
Tone1() Tone2() Tone3() Tone3()
Tone1() Tone2() Tone3()
Tone1() Tone2() Tone3() Tone3()
Tone1() Tone2() Tone3()
Tone3() Tone3() Tone2() Tone2() Tone1()
end sub
sub procedure ToneA() ‘ Tones used in Melody2 function
Sound_Play( 880, 50)
end sub