B
B
Babay2019-09-17 11:54:39
Arduino
Babay, 2019-09-17 11:54:39

How to send UART commands between mega and pic?

There is a mega 2560 and pic 18F4620 and at the peak the "higher" programmers have already written the firmware, leaving me only the grail with instructions. The bottom line is that I can’t execute these commands and I have no idea how to do it. The circuit is assembled and it definitely works, but the peak does not want to answer me. What to do and where to dig? I've been suffering for a couple of weeks now and have tried many options.
Command example
Command Response
F5 01 00 55 FE FA 01 00 55 FE
My code

void setup() {
  Serial.begin(19200, SERIAL_8N1);
  Serial1.begin(19200, SERIAL_8N1);

void loop() {

  if (Serial.available()) {
    Serial.write(Serial.read());
  }
  if (Serial1.available()) {
    Serial.write(Serial1.read());
  }
  Serial1.write("F5110055FE");
  delay(20);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
PrAw, 2019-09-17
@Babaq

1. Take a USB UART adapter, poke the PIC and try sending data with the handles. At the same time, decide where RX, TX
2 is. Do not forget to send HEXADECIMAL data, not a string

byte message[] = {0xF5, 0x01, 0x00};
Serial1.write(message, sizeof(message));

3. Check with the higher mind if you are connecting at the right speed.

L
lonelymyp, 2019-09-17
@lonelymyp

Your commands seem to be in hex, but you send a string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question