Hi all, hope your all well and safe.
Im fairly new to building micro-controllers and Arduino code, iv built a PCB board that contains 3 micro processors for a project, see below.
Main MPU (MPU) - MK20DX256VLH7 (Basic Teensy 3.2 schematic)
Navigation (NAV) - ATSAMD21G18A-AU (Sparkfun Dev)
Communication (COM) - ATSAMD21G18A-AU (Sparkfun Dev)
The NAV computer contains all the code for reading GPS, Accelerometer, Barometer, Gyro, Magnetometer etc, which is all done over IC2 to pins PA22 & PA23. However the IC2 two wire between the NAV and MPU is on pins PA08 & PA09 (Pins 18 & 19 on teensy) which I have enabled using PinPeripheral on the NAV computer and tested this using the Accelerometer which I'm getting data. so I know these pins are enabled and reading data.
However the next test I was trying to transmit simple serial write/read "Hello" using the PinPeripheral ("wiring_private.h") on the NAV computer to the MPU on the (<Wire.h>) but can't get a read!
After iv accomplished this the next step would be to transfer all the data from the sensors on the NAV computer to the MPU where I can then log data to an SD card and transmit selected data to the COM computer using the PinPeripheral IC2 pins. To then transmit to the ground over a 900Mhz radio.
See below the code iv been using to test master / slave for serial ""hello"
Master Sender (NAV) SAMD21
#include <Wire.h>
#include "wiring_private.h" // pinPeripheral() function
int led = LED_BUILTIN;
void setup()
{
pinMode(led, OUTPUT);
myWire.begin(8); // join i2c bus (address optional for master)
}
byte x = 0;
void loop()
{
digitalWrite(led, HIGH); // briefly flash the LED
myWire.beginTransmission(8); // transmit to device #8
myWire.write("x is "); // sends five bytes
myWire.write(x); // sends one byte
myWire.endTransmission(); // stop transmitting
digitalWrite(led, LOW);
x++;
delay(500);
}
Slaver Reader (MPU) Teensy 3.2
#include <Wire.h>
int led = LED_BUILTIN;
void setup()
{
pinMode(led, OUTPUT);
Wire.begin(8); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}
void loop()
{
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
digitalWrite(led, HIGH); // briefly flash the LED
while(Wire.available() > 1) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
digitalWrite(led, LOW);
}
if I could please get some help in understanding the basics on transmitting a simple ""Hello" between the two chips using two sets of IC2 wires and two wire libraries.
Also for my next prototype if any one is aware of a micro controller that is multi tread on Arduino ill be greatful if there is such a chip on market that compatible with IDE.
Your input would be much appreciated.
Thanks
Michael