common pins USART and TWI

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

Hi Evenrybody!

 

In some case XMEGA has common clock pin for USART and  TWI.

It is possible to use UART (wihtoun clock) and TWI together where clock is mapped to TWI?

Anybody has ecxpereince about. It can works?

 

Thanks for any advise.

This topic has a solution.
Last Edited: Wed. Jun 28, 2017 - 02:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It would be better to place Serial and I2C on different pins.
However the Serial is a push-pull output. So it should be able to 'overcome' the 2k2 pullups on the I2C bus.
The I2C is an open-drain output. Note that you will have to disable/deselect any MAX232 or USB chip when not using the Serial. The MAX232 does not have a 3-state pin. But the modern variants do.
.
Bear in mind that any I2C slaves on the bus might respond to particular TX and RX sequences. e.g. if you get an asynchroous i2c_start
.
David.

Last Edited: Wed. Jun 28, 2017 - 11:39 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not familiar with the parts, but do they actually have separate hardware for UART and TWI?

 

If they don't, that answers the question!

 

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For example, PORTC of xmega128A1U has TWIC and USARTC0, but if used as UART it can be used simultaneously.

I am actually doing it.

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

Common clock?  Yes, USART (the S stands for sync) but most use it in its async mode so the clock pin is not used, so would be free for any other use including TWI, so there would not be a conflict. 

 

 

Jim

 

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

Sorry guys, maybe my explanation was too short.

 

We wish to use for example USARTC0 as UART with internal clock to connect serial device (XCK0 not used), and TWIC to connect to TWI (I2C®©™) devices.

Unfortuantely we occupy near all pin of XMEGA, so we have no chance to swap.

 

But acording answer of Rookie and Jim  we design in this way.

 

Thank you guys

 

 

 

Last Edited: Wed. Jun 28, 2017 - 02:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Write down your complete pin budget and target device. I bet that someone will be able to suggest a solution.
Most Xmegas have got a reasonable number of pins.
.
David.

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

We already selected Xmega256A3BU with many reason.

Our production require TQFP package.

 

 

 

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

david.prentice wrote:
Write down your complete pin budget and target device. I bet that someone will be able to suggest a solution. Most Xmegas have got a reasonable number of pins. . David.

 

What david is suggesting is list your uses of the pins, perhaps we can suggest ways to better utilize the pins you have without changing the MPU. 

 

example: if buttons are involved, normally,  one uses one pin per button, but as long as only one button at a time is pressed, you can use one analog pin to "read" one of multiple buttons, thus saving n-1 pins. 

 

Jim

 

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

USARTC0 as UART with internal clock to connect serial device (XCK0 not used), and TWIC to connect to TWI (I2C®©™) devices.

There is no problem, the SCL line's alternate pin functions only come into play if you enable those functions otherwise it's SCL use only after you enable the TWIC.

 

ie Pins 16 and 17 are TWIC, pins 18 and 19 are USARTC0 in USART mode. If, on the other hand, you wanted to use USARTC0 in SPI mode then you would lose the TWI function.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Thanks again guys.

But unfortunately we have limitations.

We need to maintain compatibility, we have PCB limitations and we have time limit.

It maybe have better pin assignment, but we have no chance to use for this project.