Close

Joy in 1cm sq. board by ATtiny10

A project log for Minimalist A-go-go

A project inside Attiny. I will not step out for larger one till I complete it.

kodera2tkodera2t 04/06/2016 at 11:470 Comments

And I am trying even more smaller MCU, ATtiny 10, actually its size is identical to general switching transistor. But even in such a small package, it has 4ch 8bit A/D converter with 1024 words flash memory. 6pin is not enough to support full SPI writing but there is a special way, TPI (details can be found in websites) but we don't need to worry about TPI. ATmel Studio with Atmel ICE fully supports its programming.

Here is actual prototype board putting ATtiny10 for 6-pin dip break out. On the surface....

Two LEDs and resisters are put to organise "voltage indicator"

This is a actual wiring information between ATtiny10 and ATmel ICE. MOSI has no connection but binary transfer is supported by Atmel Studio.

The following simple assembly code enables tiny voltage indicator...

.def r_temp1 = R16
.def r_temp2 = R17
.def r_temp3 = R18

.equ lv_1 = 0x40 ; values for voltage comparison
.equ lv_2 = 0x80
.equ lv_3 = 0xC0

setup:                
ldi	r_temp1, ((1<<ADEN)+(1<<ADSC)+(1<<ADATE)+(1<<ADIE)+(0<<ADIF)+(1<<ADPS2)+(1<<ADPS1)+(1<<ADPS2))
out   ADCSRA,r_temp1       
;starting A/D conversion (free running mode)
ldi	r_temp1, ((1<<MUX1)+(0<<MUX0)) ; input A/D = PB2
out   ADMUX,r_temp1
; setting PB2 for A/D input
ldi	r_temp1, ((0<<DDB2)+(1<<DDB1)+(1<<DDB0))
; PB0 and 1 are LED out
out	DDRB, r_temp1 
; PB0, 1 for LED output (PB2 for input)

main: ; main loop start!
in    r_temp1,ADCL        
;reading lower bit of A/D result

cpi r_temp1, lv_1 ; comparing measured result with lv_1=0x2b
brlo s_vchk_1 ; if the measured value is lower than 0x40, jump to s_vchk_10

cpi r_temp1, lv_2 ; comparing measured result with lv_2=0x80
brlo s_vchk_2

cpi r_temp1, lv_3 ; comparing measured result with lv_3=0xC0
brlo s_vchk_3

rjmp main ; closing main loop

s_vchk_1:
	ldi r_temp3, 0x00 ;all LED are off (positive logic)
	out PORTB, r_temp3
	ret ; return to main loop

s_vchk_2:
	ldi r_temp3, 0b00001 ;PB0 is on
	out PORTB, r_temp3
	ret ; return to main loop


s_vchk_3:
	ldi r_temp3, 0b00011 ; PB0, 1 are on
	out PORTB, r_temp3
	ret ; return to main loop
"ATtiny10" memory use summary [bytes]:
Segment   Begin    End      Code   Data   Used    Size   Use%
---------------------------------------------------------------
[.cseg] 0x000000 0x00002e     46      0     46    1024   4.5%
[.dseg] 0x000040 0x000060      0      0      0      32   0.0%
[.eseg] 0x000000 0x000000      0      0      0       0      -
Assembly complete, 0 errors. 0 warnings
According to Atmel Studio, Attiny10 is well enough to accommodate my short code and still has lots of room! (Seems just 4.5% of capacity is using...)

Actual operation can be found in the following movie... have fun!

Discussions