คือผมรู้แค่ว่าในตัว MEGA 2560 มี SPI อยู่แค่ชุดเดียวคือ ขา 50-53 โดยที่ขา 53 จะเป็นขา Slave Select ซึ่งหากผมจะใช้กับโมดูลหลายๆตัวที่ใช้ SPI ผมก็ไม่รู้จะหาขา SS ได้จากไหนครับ พอดีจะใช้ SD-CARD ควบคู่ไปกับ nRF24L01p ครับ
รบกวนด้วยครับผม
ขอบคุณครับ
ทำได้ครับ ขา SPI ต่อทับกันได้ จะมีที่แยกคือขา CS/SS ที่เป็นตัวเลือกว่าจะให้อุปกรณ์ตัวไหนทำงาน โดยปกติเป็นสถานะ 1 ถ้าเป็นสถานะ 0 แสดงว่าเลือกให้อุปกรณ์นี้ทำงาน ซึ่งขา CS/SS เป็นขา Digital ดังนั้นใช้ได้ทุกขาครับ
ขา CS/SS เหมือนเคยได้ยินว่าได้แค่ขา 4,8,10,53 ไม่เป็นความจริงครับ
อ้างอิงจาก https://www.arduino.cc/en/Reference/SPI
All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master. Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative.
It is, however, possible to use any pin as the Slave Select (SS) for the devices. For example, the Arduino Ethernet shield uses pin 4 to control the SPI connection to the on-board SD card, and pin 10 to control the connection to the Ethernet controller.
ตามหลักการทำงานของอินเตอร์เฟส SPI ครับ CS/SS ที่เป็นตัวเลือกว่าจะให้อุปกรณ์ตัวไหนทำงาน โดยปกติเป็นสถานะ 1 ถ้าเป็นสถานะ 0 การเซตค่า 0 หรือ 1 ก็คือขา digital ทุกขาของ Arduino เป็น digital ได้ครับ
ทดสอบแล้วกับ SD Card อินเตอร์เฟสแบบ SPI ขา CS/SS ใช้ได้ทุกขา ในรูปใช้ขา CS/SS เป็น A0