Attiny1614 One-Wire Errata Datasheet Errors

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

Per request of Jim, publishing this in it's own thread.

originally reported here... https://www.avrfreaks.net/comment/2769991#comment-2769991

 

ATTINY1614

 

Datasheet says on pg337; "When the USART is set in one-wire mode, the transmitter and the receiver share the same RxD I/O pin."; (that is wrong)

One-Wire pin is the TXD pin, NOT THE RXD PIN

Microchip has confirmed that TXD is the correct pin for One-Wire. I'm in the process of trying to get Microchip to update the datasheet.

 

Also not specified in the datasheet for One-Wire mode...

If TX pin is set as output, ODME "Open Drain Mode Enable" does not work.
so TX port must NOT be set as output when using ODME "Open Drain Mode Enable".
This is Not specified in the datasheet.

 

The following statement from pg340 about one wire setup is vague.
For setting the USART in One-Wire mode, the following initialization sequence is recommended:
1) Set the TxD/RxD pin value high, and optionally set the XCK pin low.
*Needs clarification, what does "Set the TxD pin value high" mean, pullup resistors? or set as output?
*testing shows that in open drain mode, pin should NOT be set as output
2) Optionally, write the ODME bit in the USARTn.CTRLB register to '1' for Wired-AND functionality.
3) Set the TxD/RxD and optionally the XCK pin as an output.
4) Select the baud rate and frame format.
5) Select the mode of operation (enables XCK pin output in Synchronous mode).
6) Enable the transmitter or the receiver, depending on the usage

 

Tested and working method for 1 wire.
1) Do NOT set TxD pin as output
2) Enable Pullup Resistor on TxD pin if NOT using external pullup.
3) set bit LBME "Loop-back Mode Enable"
4) set bit ODME "Open Drain Mode Enable"
5) Use TxD pin for Transmit and Receive operations.
6) Enable the transmitter or the receiver, depending on the usage

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

I'm sorry but it's still unclear to me how I should use this. I want to use RS-485 on an ATtiny1614 in half-duplex mode with an external driver and minimal pins.

 

To start, do I get this right that with one-wire mode I only need to connect a single pin for both send and receive operation, and I can still both send and receive in half-duplex mode without any special code that would switch between modes? The instruction "Enable the transmitter or the receiver, depending on the usage" sounds like I should only use one not both.

 

Do I need to enable ODME mode? I'm not sure what consequences that has. I have a MAX485 chip here and would simply connect both its ~RE and DE pins to ATtiny's XDIR, and both RO and DI to ATtiny's TxD. Is there anything else I need to wire up? Also, how can I enable an internal pull-up resistor for the TxD port? That data sheet doesn't explain this at all or uses a word I can't find with the search function. Is the LBME loopback mode the key to enable the one-wire mode? If so, why isn't it named the same, with no indication that they're related?

 

I also couldn't find other sources on the web that would show example code and the wire configuration of this use case.

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

Welcome to AVRFreaks!

 

Well, this is two different things, rs485 has nothing to do with one-wire mode!

For 485, you setup the usart in a normal mode and use a 485 transceiver chip, along with one port pin to control direction of the bus. 

 

One-wire mode is used to talk to one-wire devices such as buttons, rt-clocks, temp sensors, etc. Goggle Dallas One Wire for more info.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

for unified memory AVR :

AN2658 USART in One-Wire Mode

[PDF, page 1, third paragraph]

In this document, the term 1-Wire refers exclusively to the 1-Wire protocol. The term one-wire refers to any form of one-wire half-duplex communication including, but not limited, to the Dallas 1-Wire protocol.

 

"Dare to be naïve." - Buckminster Fuller

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

ki0bk wrote:

Well, this is two different things, rs485 has nothing to do with one-wire mode!

For 485, you setup the usart in a normal mode and use a 485 transceiver chip, along with one port pin to control direction of the bus. 

 

One-wire mode is used to talk to one-wire devices such as buttons, rt-clocks, temp sensors, etc. Goggle Dallas One Wire for more info.

 

Oh, that 1-Wire! Yeah, that's something else. I didn't think of that when looking at USART. And since RS-485 bus is half-duplex, and the bus itself also has just one wire (pair), I thought it would be reasonable to save a pin at the MCU, too. Well, doesn't seem to be the case then.

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

Hi ygoe! 

 

Like Ki0bk stated, One-Wire mode and RS-485 are two different operating modes for the USART. That being said, they can still be used at the same time. 

I recommend looking at the updated version of the USART documentation, found in the new revision of the ATtiny1614 data sheet (https://microchip.com/DS40002204). There you can find a better initialization section with more clear instructions, and a new figure for the RS-485 mode when used together with One-Wire mode. 

 

Here's an overview of the important configurations to make it happen:

- Set RS485[0] in USARTn.CTRLA to enable RS-485

- Set LBME in USARTn.CTRLA to connect the TXD pin to the USART receiver (and hence disconnect the RXD pin which now may be used elsewhere)

- Open-Drain mode is perhaps not important here, since the line driver already ensures that you don't receive at the same time as transmitting (ensuring that you don't send a 1 while receiving a 0, creating a short).

- Set the TXD pin to output in the corresponding PORTx.DIR register (but if you do enable Open-Drain mode, it should be input)

- Enable TX and RX in USARTn.CTRLB

 

I see that it's a while since you posted a question, so you might already be done with your project. If not, please let me know if I can help further.

 

Best regards,

Amund