I have a a CPLD (Lattice MachXO2) that echos a signal from an Arduino to turn on an LED.
Arduino:
//send out .1s pulse on output pin 2 when a 'q' is recieved
void loop () {
USBinByte = Serial.read();
if (USBinByte == 'q') {
digitalWrite(ledPin, HIGH);
delay (100);
digitalWrite(ledPin, LOW);
}
}
CPLD:
//When LEDin goes high toggle LED
module toggleLED (
LED,
LEDin);
output LED;
input LEDin;
reg LED;
assign led_next = ~LED;
always @(posedge LEDin) begin
LED = led_next;
end
endmodule
How do I setup I2C on both chips to be able to load an 8 bit register on the CPLD and also read the register, so I can set up multiple LEDs? I've done I2C between three Arduinos before using the WIre library. I2C is required for a project I'm working on.