search for uart tx/rx example for codevision

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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 :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use a 9th data bit as an L/H byte marker, and you'll always be in sync.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
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...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Only in the commercial version I believe...

IIRC it is interrupt-driven serial comms that is a licensing restriction for the Wizard.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

CodeVision Examples

Attachment(s): 

We never have time to do it right,
but we always have time to do it over

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do I need to use UART translate int numbers into strings/chars (send 0x31 - char code of '1', instead send 0x01)?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
    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.