TWI Register Names - ATtiny817

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

I am working with the ATtiny817 using the ATtiny817 Xplained Mini board and Atmel Studio 7. I posted yesterday about my difficulty in getting TWI libraries to work with ATtiny817, and was told I need to either try and adapt the XMega TWI library for the ATtiny817, or create a new one from scratch. I'm currently working on adapting the XMega TWI library, and have attempted to scale it way down to just simple init, start transmission, write, and read functions without using interrupts (which I may add back in, but I thought starting with the bare minimum would be a good starting place). However, Atmel Studio is not recognizing the use of ATtiny817 TWI register names found in the datasheet (such as MBAUD, MDATA, MADDRESS, etc).  As the datasheet also references them sometimes as TWI.MBAUD, I've tried prefixing the name with TWI, but it still doesn't work.  What is the correct way to reference these registers? I've included my main.c and TWI_master_driver.c files, please let me know if any more information would be helpful. 


Last Edited: Fri. Nov 18, 2016 - 06:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please keep this to one thread.




(locked to avoid cross posts).


EDIT unlocked temporarily to say you can see this in iotn817.h:

/* Two-Wire Interface */
typedef struct TWI_struct
    register8_t CTRLA;  /* Control A */
    register8_t reserved_0x01;
    register8_t DBGCTRL;  /* Debug Control Register */
    register8_t MCTRLA;  /* Master Control A */
    register8_t MCTRLB;  /* Master Control B */
    register8_t MSTATUS;  /* Master Status */
    register8_t MBAUD;  /* Master Baurd Rate Control */
    register8_t MADDR;  /* Master Address */
    register8_t MDATA;  /* Master Data */
    register8_t SCTRLA;  /* Slave Control A */
    register8_t SCTRLB;  /* Slave Control B */
    register8_t SSTATUS;  /* Slave Status */
    register8_t SADDR;  /* Slave Address */
    register8_t SDATA;  /* Slave Data */
    register8_t SADDRMASK;  /* Slave Address Mask */
    register8_t reserved_0x0F;
} TWI_t;

and then later:

#define TWI0                  (*(TWI_t *) 0x0810) /* Two-Wire Interface */

So things like TWI0.MCTRLA should be accessible.


This is just standard C - you should have been able to get that from reading the .h file.

Last Edited: Fri. Nov 18, 2016 - 06:34 PM
Topic locked