CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account
You are here: Home / GizmoBlog / MMBasic Language / Input and Output / SPI

SPI

SPI( rx, tx, clk[, data[, speed[, mode[, bits]]]] )

Sends and receives a byte using the SPI protocol with MMBasic as the master (ie, it generates the clock).

‘rx’ is the pin number for the data input (MISO)

‘tx’ is the pin number for the data output (MOSI)

‘clk’ is the pin number for the clock generated by MMBasic (CLK)

‘data’ is optional and is an integer representing the data byte to send over the data output pin. If it is not specified the ‘tx’ pin will be held low.

‘speed’ is optional and is the speed of the clock. It is a single letter either H, M or L where H is 500KHz, M is 50KHz and L is 5KHz. Default is H.

‘mode’ is optional and is a single numeric digit representing the transmission mode. The default mode is 3.

‘bits’ is optional and represents the number of bits to send/receive. Range is 1 to 23 (this limit is defined by how many bits can be stored in a floating point number). The default is 8.

Mode CPOL CPHA Description
Mode: 0 (Clock polarity: 0 Clock phase: 0) Clock is active high, data is captured on the rising edge and output on the falling edge
Mode: 1 (Clock polarity: 0 Clock phase: 1) Clock is active high, data is captured on the falling edge and output on the rising edge
Mode: 2 (Clock polarity: 1 Clock phase: 0) Clock is active low, data is captured on the falling edge and output on the rising edge
Mode: 3 (Clock polarity: 1 Clock phase: 1) Clock is active low, data is captured on the rising edge and output on the falling edge

See also:
SETPIN

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2021 · Generate Pro Theme on Genesis Framework · WordPress · Log in