Go Down

Topic: Arduino Communication with a Texas Chip Over Serial (Read 76 times) previous topic - next topic

Rorschac

Hi, I have a BQ76PL455 ti. I want to communicate this chip with Arduino. But I did not find a way to send a hex. When I try to send the following code, the Arduino compiler gives an overload error.

Code: [Select]


void setup() {
 
Serial1.begin(250000);
}

void loop() {
 
    Serial1.write(0x8901000A00DA83);
  }
}




I added the PDF of the TI chip in case anyone wanted to review it.

http://www.ti.com/lit/an/slva617a/slva617a.pdf

Thank you from now.


el_supremo

You need to store each pair of hex digits as a separate byte:
uint8_t msg[] = {0x89, 0x01, 0x00, 0x0A, 0x00, 0xDA, 0x83};

and then you can write it like this:
Code: [Select]
Serial1.write(msg,sizeof(msg));

Pete
Don't send me technical questions via Private Message.

Rorschac

#2
Jun 13, 2018, 12:58 am Last Edit: Jun 13, 2018, 01:03 am by Rorschac
Thank you for your answer.

Also response will be hex too. Which variable should I save this response? Should I parse this coming message too?

el_supremo

Quote
Also response will be hex too.
No, it will be in binary which is also what you will send. Hex is just a way to represent the value in a byte. If a byte has a hex value of 0x12 you equally have written this in decimal as 18 or in binary as 0B00010010. If you're an old geezer like me you could even write it in octal as 022. They all represent the same quantity.

Quote
Which variable should I save this response?
Depends how long the response will be. You could also re-use this same variable for other responses, in which case you would declare it to be as long as the longest response that you are expecting. If all responses are going to be less than, for example, 20 bytes then I'd declare a variable to have 24 bytes just to be sure.
Code: [Select]
uint8_t response[24];

Quote
Should I parse this coming message too?
You should always check whatever response you get to make sure that whatever message you've just sent was received correctly.

Pete
Don't send me technical questions via Private Message.

Go Up