Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m doing a microcontroller lab and i\'m stuck at the section where I need to m

ID: 3760330 • Letter: I

Question

I'm doing a microcontroller lab and i'm stuck at the section where I need to modify my last code to interface with new IC. So my old code was interfacing with I2C and the new code that I'm struggling with is SPI [MCP23S08]. I will attach my code. I need help to modify my old code to do the same behavior with the SPI ic.[ note i'm using Arduino compilor]

1:I need a full description of my old code I2c, and what's happening in setup() function and whats happening during the loop() function.

2:the same on the SPI code

The Code is:

#include

void setup() {
Wire.begin();

Wire.beginTransmission(32);
Wire.write(byte(0x20));
Wire.write(byte(0x00));
Wire.endTransmission();
}

byte val=0;
void loop() {
Wire.beginTransmission(32);
Wire.write(byte(0x09));
Wire.write(byte(val));
Wire.endTransmission();

val++;
if (val==256) {
val=0;
}
delay(500);
}

Explanation / Answer

inthe first part you mentiond
setup out direction registers
pointer
DDR port input and output
DDR Port1 all output
but you didnt mentioned specefied librery and clear bits and invert bits
comming to the loop

byte value you declared 0
your are expecting 256 bytes, so check you got them
where did you print your result.
you didnot set the data pionter
you did not mentioned your old code here.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote