0

I want to transmit serial data from ARM MCU to PIC MCU in Mikro C. How can I sent multiple parameters in the same UART Channel? For example, the ARM Processor has temperature and distance information which are both a number. What should be done in order that PIC can understand which number belongs to which parameter? I thought it would be useful to add prefix letters to the numbers. Am I right?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Obuyuk
  • 9
  • 1
  • Too broad dude. Are you talking about half or full duplex? RS232, RS485, TTL connection.... You can develop your own protocol or refer to a standard, such as [ModBus](http://www.simplymodbus.ca/ASCII.htm). [A little simple guide](http://www.commfront.com/RS232_Protocol_Analyzer_Monitor/RS232_Analyzer_Monitor_Tester_Tutorial2.htm) – LPs Sep 10 '15 at 12:07
  • Thank you for comment. I am talking about full duplex communication between ARM STM32F407 and PIC18F46K22 microprocessors. I used neither RS232 nor TTL. Just connected UART TX pin of ARM MCU's to the UART RX pin of PIC MCU and UART RX pin of ARM MCU to the UART TX pin of PIC MCU. – Obuyuk Sep 10 '15 at 13:35

1 Answers1

2

You need some kind of protocol that makes this information available.

Yes, prefixing is one solution. It's certainly terse, which can be handy if performance is critical.

If using a text-based protocol, I would also suggest using a clearly-defined terminator for each message (e.g. \n) to make the receiver's job as easy as possible.

It could just be:

t=43.2
d=541.42

I added an equals sign to make it a bit clearer. No idea if your numbers are floats or integers, of course. Line-feeds are implied in the above.

unwind
  • 391,730
  • 64
  • 469
  • 606
  • If performance is that critical, then maybe some binary format would be a better option. Decoding base10 numbers from the text input on a weeny 8 bit controller could be nasty, requiring divisions (by constant, though). Even hexadecimal is a lot better. – Jubatian Sep 10 '15 at 15:53