FastHWSPITransfer

Syntax:

  FastHWSPITransfer tx

Command Availability:

Available on Microchip PIC microcontrollers with Hardware SPI modules.

Explanation:

This command only sends a byte of data using the SPI protocol. This command only supports master mode.

As a master, FastHWSPITransfer will initiate a transfer. The data in tx will be sent to the slave.

Example:

This is an example for this command.

Master Program:

  'General hardware configuration
  #chip 16F877A, 20

  'Set SPI pin directions
  dir PORTC.5 out
  dir PORTC.4 in
  dir PORTC.3 out

  'Set SPI Mode to master, with fast clock
  SPIMode MasterFast

  'Main Loop
  do

      'Send the value of 0x55
      FastHWSPITransfer 0x55          ' <<< the FastHWSPITransfer instruction

  loop

Key line: FastHWSPITransfer 0x55 — sends the byte 0x55 to the slave without waiting to receive a reply; because it discards any incoming byte, this is faster than SPITransfer when the slave’s response is not needed.

See Also:

  • SPITransfer — the full send-and-receive equivalent of this command
  • SPIMode — selecting master mode before transferring, as used above