Getting started ATtiny 1 & 0 series / Application Notes

Go To Last Post
55 posts / 0 new

Pages

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

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

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

DrDavid wrote:
 I did not see any library entries in the GCC documentation for either the EEProm or the TWI. 
Your probably looking in the wrong place - try start.atmel.com (and contemplate why that's still in the "atmel" domain not the microchip domain! ;-)

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

avr-libc hasn't caught up yet with this chip family.

 

There is a new Arduino core (https://github.com/SpenceKonde/D...) that will give you some working code. The EEPROM code is known to work as I have an AVR128DA28 here in front of me. The I2C (Wire) library as works well.

 

Or you could install MPLABX and use MCC to generate some code.

 

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

obdevel wrote:
avr-libc hasn't caught up yet with this chip family.
You sure? I just built:

#include <avr/io.h>
#include <avr/eeprom.h>

uint16_t EEMEM foo;

int main(void)
{
	eeprom_write_word(&foo, 12345);
	asm("nop");
	TCA0.SINGLE.CNT = eeprom_read_word(&foo);
	while (1)
	{
	}
}

which generated:

int main(void)
{
	eeprom_write_word(&foo, 12345);
  fe:	69 e3       	ldi	r22, 0x39	; 57
 100:	70 e3       	ldi	r23, 0x30	; 48
 102:	80 e0       	ldi	r24, 0x00	; 0
 104:	90 e0       	ldi	r25, 0x00	; 0
 106:	0d d0       	rcall	.+26     	; 0x122 <eeprom_write_word>
	asm("nop");
 108:	00 00       	nop
	TCA0.SINGLE.CNT = eeprom_read_word(&foo);
 10a:	80 e0       	ldi	r24, 0x00	; 0
 10c:	90 e0       	ldi	r25, 0x00	; 0
 10e:	05 d0       	rcall	.+10     	; 0x11a <eeprom_read_word>
 110:	80 93 20 0a 	sts	0x0A20, r24	; 0x800a20 <__TEXT_REGION_LENGTH__+0x7e0a20>
 114:	90 93 21 0a 	sts	0x0A21, r25	; 0x800a21 <__TEXT_REGION_LENGTH__+0x7e0a21>
 118:	ff cf       	rjmp	.-2      	; 0x118 <main+0x1a>

0000011a <eeprom_read_word>:
 11a:	0a d0       	rcall	.+20     	; 0x130 <eeprom_mapen>
 11c:	80 81       	ld	r24, Z
 11e:	91 81       	ldd	r25, Z+1	; 0x01
 120:	08 95       	ret

00000122 <eeprom_write_word>:
 122:	0a d0       	rcall	.+20     	; 0x138 <eeprom_write_byte>
 124:	27 2f       	mov	r18, r23
 126:	09 c0       	rjmp	.+18     	; 0x13a <eeprom_write_r18>

00000128 <eeprom_read_byte>:
 128:	03 d0       	rcall	.+6      	; 0x130 <eeprom_mapen>
 12a:	80 81       	ld	r24, Z
 12c:	99 27       	eor	r25, r25
 12e:	08 95       	ret

00000130 <eeprom_mapen>:
 130:	fc 01       	movw	r30, r24
 132:	e0 50       	subi	r30, 0x00	; 0
 134:	fc 4e       	sbci	r31, 0xEC	; 236
 136:	08 95       	ret

00000138 <eeprom_write_byte>:
 138:	26 2f       	mov	r18, r22

0000013a <eeprom_write_r18>:
 13a:	af 93       	push	r26
 13c:	bf 93       	push	r27
 13e:	e0 e0       	ldi	r30, 0x00	; 0
 140:	f0 e1       	ldi	r31, 0x10	; 16
 142:	32 81       	ldd	r19, Z+2	; 0x02
 144:	31 fd       	sbrc	r19, 1
 146:	fd cf       	rjmp	.-6      	; 0x142 <eeprom_write_r18+0x8>
 148:	dc 01       	movw	r26, r24
 14a:	a0 50       	subi	r26, 0x00	; 0
 14c:	bc 4e       	sbci	r27, 0xEC	; 236
 14e:	2c 93       	st	X, r18
 150:	2d e9       	ldi	r18, 0x9D	; 157
 152:	24 bf       	out	0x34, r18	; 52
 154:	23 e0       	ldi	r18, 0x03	; 3
 156:	20 83       	st	Z, r18
 158:	01 96       	adiw	r24, 0x01	; 1
 15a:	bf 91       	pop	r27
 15c:	af 91       	pop	r26
 15e:	08 95       	ret

Are you saying this is generating the "wrong code" for accessing the EEPROM on 128DA28 ?

Pages