[EN] SPI Bus

This article discusses the SPI bus functionality of the Arduino framework for use with the STM32F030F4P6, STM32F103C8, STM32F401, esp8266 and esp32. The operation of this bus requires at least 3 intercommunication cables: SCLK, MISO. and MOSI for transmitting the clock signal between the sender and the receiver. It serves to receive information from the sender. and used for sending information to the recipient.

From the use of 3 signal lines, it is found that data can be transmitted and received simultaneously. This is different from I2C bus communication that uses only one SDA cable to communicate. At the same communication speed, the SPI bus will receive and transmit data without waiting for an idle line, while I2C will have to wait for idle. With this in mind, SPI can send/receive data faster.

In addition, SPI uses a method to select the destination to communicate by instructing the endpoint to know by sending a signal to the SS pin of the terminal. Therefore, when connecting to multiple devices, SPI requires a larger number of pins to operate, while I2C uses device identification to communicate with each other by still using only one SDA cable, which saves more pins.

Read More

[EN] machine.SPI

From the article machine.Pin, it has been discussed using a microcontroller pin to import and export data and in the article I2C bus communication which uses the machine.I2C class to communicate between devices. Now let’s take a look at the machine.SPI class, another form of communication that has been recognized for its speed and is commonly used with a graphics display (esp8266/esp32 article) or SD-Card reader (esp8266, esp32article).

Read More

[TH] SPI Bus

บทความนี้กล่าวถึงฟังก์ชันการใช้งานของบัส SPI ของเฟรมเวิร์ก Arduino เพื่อใช้กับ STM32F030F4P6, STM32F103C8, STM32F401, esp8266 และ esp32 ซึ่งการทำงานของบัสนี้ต้องการสายสัญญาณสำหรับสื่อสารระหว่างกันอย่างน้อย 3 เส้น คือ SCLK, MISO และ MOSI สำหรับทำหน้าที่ส่งสัญญาณนาฬิการะหว่างกันของผู้ส่งและผู้รับ ทำหน้าที่รับข้อมูลจากผู้ส่ง และใช้สำหรับส่งข้อมูลไปให้ผู้รับ

จากการใช้สายสัญญาณ 3 เส้นจะพบว่า สามารถส่งและรับข้อมูลพร้อมกันได้ ซึ่งแตกต่างกับการสื่อสารแบบบัส I2C ที่ใช้สาย SDA เพียงเส้นเดียวในการสื่อสาร ดังนั้น อาจจะกล่าวได้ว่า ด้วยความเร็วในการสื่อสารที่เท่ากัน บัสแบบ SPI จะรับและส่งข้อมูลได้โดยไม่ต้องรอสายสัญญาณว่าง ขณะที่ I2C จะต้องรอให้ว่างก่อน ด้วยหลักคิดนี้จึงทำให้ SPI รับ/ส่งข้อมูลได้รวดเร็วกว่า

นอกจากนี้ SPI ใช้วิธีการเลือกปลายทางที่ต้องการสื่อสารด้วยการสั่งให้ปลายทางรู้ด้วยการส่งสัญญาณไปที่ขา SS ของอุปกรณ์ปลายทาง ดังนั้น เมื่อเชื่อมต่อกับหลายอุปกรณ์จึงส่งผลให้ SPI ต้องการจำนวนขาในการทำงานที่มากกว่า ขณะที่ I2C ใช้การระบุคำแหย่งของอุปกรณ์ในการสื่อสารระหว่างกัน โดยยังคงใช้สาย SDA เพียงเส้นเดียวทำให้ประหยัดขาได้มากกว่า

Read More

[TH] machine.SPI

จากบทความเรื่อง machine.Pin ได้กล่าวถึงการใช้งานขาของไมโครคอนโทรลเลอร์เพื่อนำเข้าข้อมูลและส่งออกข้อมูลไปแล้ว และในบทความการสื่อสารผ่านบัส I2C ซึ่งใช้คลาส machine.I2C เพื่อสื่อสารระหว่างอุปกรณ์ ในคราวนี้มารู้จักคลาส machine.SPI ซึ่งเป็นการสื่อสารอีกรูปแบบหนึ่งที่ได้รับการยอมรับถึงความเร็วในการทำงาน และนิยมใช้กับจอแสดงผลกราฟิก (บทความของ esp8266/esp32) หรือช่องอ่าน SD-Card (บทความของ esp8266, esp32)

Read More