How to use I/O PORT as USART

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

hi,
i want some information....
-> i want to use I/O ports as USART for serial Tx
-> Please suggest me how to convert i/o port to USART
-> otherwise suggest any other solution

(In my project i am using xmega128A1 ,it having 8 Identical USART peripherals,but i need still 5 so i desired to use 5 I/O ports as usart ,is it possible ????
)

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

If you have 8 hardware USARTs, it seems only sensible to use them.

To bit-bash five TX channels will have a very reduced performance.

You can do whatever you want. This does not mean that everything is wise.

David.

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

In general, 'bit banging' a serial tx is easier than recieving a char. I think 5 bitbanged tx channels is easy and doable, especially if the baud rates are low. Start by searching for 'sw uart' in projects? Might need to cvt from mega to xmega though.

Imagecraft compiler user

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

Maybe you could tell us a bit more about what you are using all these uarts for.

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

i am using all these usart for modbus communication,
(i am the beginner in this area please suggest me how to config gpio pins to use as usart)

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

modbus can address 240 devices per channel, do you need to address more than 2880 devices?

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

the output level of rx/tx is the same as rs232 on the CPU pins, there is hardware needed on the peripheral to change the level from 0-3V to -+12V.
The main work is on the software.
Transmit byte - you keep the output 0 as normal, once you start you change it to 1 (this is the start bit) and use timer to create interrupt after the needed time (according to the baud rate). every interrupt you change the level of output pin to the next bit value (LSB first). after the start bit and the 8 data bits, lets assume you don't use parity you change the value to 0 for one more bit (end bit) and you have finished sending one byte.
The receive side is using level interrupt to monitor the Start bit. once it started you need a timer interrupt to read each bit.

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

i am very very.... sorry for my late reply.
usart bit bang code:
i done Tx part,by using timer interrupts its working perfectly....but for Rx i need some example link please suggest me,is it possible to use external interrupts for receiving because i don't want to poll continuously.........