hi!
i'm search for working example of uart implementation tx/rx 15 INT numbers between two mega AVR every 2-3 seconds. self-synchronization version will be great.
thank :)
search for uart tx/rx example for codevision
You do know that the CodeWizard will write all the UART routines for you? What comes out the other end will give you getchar() and putchar() style routines. It's then up to you ho you use these to transfer the ints. While just splitting them into bytes and sending each is the most efficient transfer you may find it easier to develop/diagnose by converting the ints to ASCII first (itoa) and sending human readable strings (so you can check it's working right with a terminal on your PC). At the receiving end (assuming itoa() is used) just use atoi() to convert back into a binary representation.
Use a 9th data bit as an L/H byte marker, and you'll always be in sync.
You do know that the CodeWizard will write all the UART routines for you? What comes out the other end will give you getchar() and putchar() style routines.
Only in the commercial version I believe...
IIRC it is interrupt-driven serial comms that is a licensing restriction for the Wizard.
CodeVision Examples
Attachment(s):
Papabravo, thank you. But I don't find in example how to send ints, there is chars only. How do it best way. Also this code is only part of program.
Do I need to use UART translate int numbers into strings/chars (send 0x31 - char code of '1', instead send 0x01)?
char buf[20]; // allow a little input buffer. ... printf("%01d\r\n", TX_value); ... gets(buf, 20); RX_value = atoi(buf);
Note that gets() needs a '\n' to signal the 'end of a line'.
David.