Implementation of SPI Function-Simulink
조회 수: 20 (최근 30일)
이전 댓글 표시
Hello everyone, Im trying to implement this SPI fucntion in a Simulink block to stablish communication with my Arduino MEga 2560 . It's an easy function, the problem is i dont't know where to start, Ive read for several days information in Internet,seen tutroial about S-functions, but I found the info really confusing.This is my function code :
void setup() {}
// the loop routine runs over and over again forever:
void loop() {}
// This is the generic initialization function to set up the Arduino to communicate with the chip.
void SPI_init() {
// initialize SPI for the dSPIN chip's needs:
// most significant bit first,
// SPI clock not to exceed 5MHz,
// SPI_MODE0 (clock idle low, latch data on rising edge of clock)
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV16); // System clock: 16MHz; Stepper SPI runs at 1MHz
SPI.setDataMode(SPI_MODE0);
Serial.println("SPI configured!");
}
I would really apreciate if someone could help me out :) :)
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 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!