AVR128DA TWI Dual-Mode Confusion...

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

I was just turned onto the new DA series and well, wow...they look really impressive! I am having a bit of trouble with the addition of the 2nd TWI bus, specifically 'Dual-Mode', or rather !Dual-Mode. Dual-mode makes sense: 1 bus is for master operations, the other for slave operations.

 

But what happens when Dual-Mode is inactive? Do we have 2 independent normal TWI interfaces? Or are both busses joined together as if there's a repeater between them? It looks as if the Register Summary of the datasheet is pointing towards the latter, as I don't see MSTATUS0 and MSTATUS1, for instance.

This topic has a solution.
Last Edited: Tue. Jul 28, 2020 - 10:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sothis wrote:
I was just turned onto the new DA series and well, wow

Sothis wrote:
But what happens when Dual-Mode is inactive?

Welcome to the bleeding edge of AVRs, post your solution when you figure it out!

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

Its not that complicated. The DUALCTRL simply changes which set of pins to route to the slave side (and its pin properties, since the master pin properties no longer apply).  If enabled, you get the set selected in the portmux setting, if not enabled you get the same set of pins as the master. In either case the master and slave are essentially two peripherals.

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

Sothis wrote:
I don't see MSTATUS0 and MSTATUS1, for instance.

 

This link shows the TWI_struct, and typedef.

 

https://github.com/epccs/PiUpdi/blob/master/lib/AVR-Dx_DFP/include/avr/ioavr128da28.h#L2216

 

TWI0 is defined to be that typedef.

 

https://github.com/epccs/PiUpdi/blob/master/lib/AVR-Dx_DFP/include/avr/ioavr128da28.h#L2601

 

So I guess you would use things like TWIn.MSTATUS to access its bit field rather than something like MSTATUSn.

 

 

I see them, but do not understand the modes (e.g., Dual-Mode).

my projects: https://github.com/epccs

Debugging is harder than programming - don’t write code you can’t debug! https://www.avrfreaks.net/forum/help-it-doesnt-work

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

curtvm wrote:
Its not that complicated. The DUALCTRL simply changes which set of pins to route to the slave side (and its pin properties, since the master pin properties no longer apply).  If enabled, you get the set selected in the portmux setting, if not enabled you get the same set of pins as the master. In either case the master and slave are essentially two peripherals.

Well ya, that part makes sense, but the parametric search and even the datasheet say there's 2 i2c busses. So does that mean if dual mode was enabled on both busses you'd have 4 sets of i2c pins active (TWI0 MSDA & MSCL, TWI0 SDSA & SSCL, TWI1 MSDA & MSCL, TWI1 SSDA & SSCL)? That can be really, really powerful if so.

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

ron_sutherland wrote:
So I guess you would use things like TWIn.MSTATUS to access its bit field rather than something like MSTATUSn.

AHH, I see. That makes sense Ron!

 

I've got you to blame for this. cheeky After reading the datasheet based on your recommendation, I admit I was quite excited about all of the new possibilities with these chips!

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

Sothis wrote:
I admit I was quite excited about all of the new possibilities with these chips

 

Those chips are going to cause me to redo all the boards I have done so far... haha... what a pain, I am angry and happy, I don't know what to think.

my projects: https://github.com/epccs

Debugging is harder than programming - don’t write code you can’t debug! https://www.avrfreaks.net/forum/help-it-doesnt-work

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

>Well ya, that part makes sense, but the parametric search and even the datasheet say there's 2 i2c busses. So does that mean if dual mode was enabled on both busses you'd have 4 sets of i2c pins active

 

 

Its still not complicated. You can have 10 Twi's, and it still is the same as having 1.

 

Twi0 uses a pair of pins. Twi9 uses a pair of pins. The Portmux peripheral selects which pins to use for TwiN, and in the case when dual mode is enabled, splits out the slave pins to some other pair.

 

So if the portmux allows each Twi to use pins that do not conflict with the other (true in all cases), then if both twi's are in dual mode you have 2 masters and 2 slaves all on different sets of pins.

 

 

 

Attachment(s): 

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


Tip #1 for how to put the image in the post:

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@curtvm, OK I missed that brilliant image. Thank you for that!! This is the behavior I was hoping for.

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

ron_sutherland wrote:
Those chips are going to cause me to redo all the boards I have done so far... haha... what a pain, I am angry and happy, I don't know what to think.

I got lucky in that I'm finishing up a design that will require another HW revision anyhow so the new chip won't be too much trouble from the hardware perspective. I am (purposely) ignoring/blocking out that all I'll have to re-write everything code-wise, so I'm still just happy for now. That will no doubt change, haha.

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

>Tip #1 for how to put the image in the post:

 

I use Tip #0 as I don't want to make everyone look at some random image on the internet, unless they want to. Clink a png link, see an image, don't click, don't see, your choice.

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

But it's not just "some random image" - it's a key part of the description

 

Much easier to have it visible in context with the text - rather than having to view it in isolation.

 

and:

In #10, Sothis wrote:
I missed that brilliant image

So I rest my case, m'lud.

 

@Sothis: time to mark the solution, then?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I needed to see the image also so +1 for awneil

my projects: https://github.com/epccs

Debugging is harder than programming - don’t write code you can’t debug! https://www.avrfreaks.net/forum/help-it-doesnt-work