- Dev refers to the connected SPI device object.
- DataIn refers to the data which you want to write or read from the connected device. DataIn takes input as multiple formats (scalar, vector, hexadecimal, or binary). This format is dependent on the SPI device. The format is specified in the datasheet for the device which you are communicating with. In the examples, the dataIn values are different depending on which device is used. The EEPROM accepts data as [writeCmd address data]. The writeCmd is used as a flag to indicate that the data needs to be written at the specified address.
writeRead on SPI devices
5 ビュー (過去 30 日間)
古いコメントを表示
Hi Matlab Community,
I would like to communicate with SPI device (MAX6675) on matlab. However, I found a link that Communicate with SPI Device on Arduino® Hardware and I am doubt with the function writeRead because I couldn't find more detail explaination on writeRead function. It required two inputs, dev and dataIn. What did dataIn does exactly?
writeRead(d_pot, [hex2dec('12'), regVal], 'uint8');
In the example https://www.mathworks.com/help/supportpkg/arduinoio/examples/communicate-with-spi-device-on-arduino-hardware.html , the dataIn is [hex2dec('12'), regVal]. What did dataIn do to the d_pot exactly?
I also don't understand the outpot of writeRead in the figure(capture).
Please help me if you have any thought on this. Thank you.
0 件のコメント
採用された回答
Harshit Saini
2022 年 12 月 22 日
To communicate with SPI devices, you can use the single “writeRead” function to both write or read data to the device. It takes in two inputs: dev and dataIn.
Additionally, the output is returned as a vector of zeros to indicate that the write operation was successful. As the “writeRead” function is used to read and write from a device, the returned output refers to the read operation of the function. Since, there is no read operation taking place when we are writing to the device, the output is zero. Zero indicates a successful write operation.
Refer to the datasheet of MAX6675 to understand the data format required to communicate with the device.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Troubleshooting in MATLAB Support Package for Arduino Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!