Nugroho's blog.: microcontroler
Showing posts with label microcontroler. Show all posts
Showing posts with label microcontroler. Show all posts

Thursday, May 21, 2015

Serial Communication ATTiny13A (#1)

ATTiny didn't come with TX/RX Pins, so I have to make it by myself. 

Got it from http://www.bot-thoughts.com/2012/12/attiny-software-serial-tx-in-assembly.html
Slightly modify it because avra didn’t compile it original source

.include "../tn13Adef.inc" ; definitions for ATtiny13A
.cseg
.org 0x00
rjmp start ; executed after reset

start:
    ldi r16, 0x6D ; 'm' 
    ldi r17, 8 ; put 8 in counter register
txloop:
    lsr r16 ; shift off the next bit, LSB first
    brcs Send1 ; if it is 1 (C=1) then send 1
Send0:
    cbi PORTB, PB0 ; send a 0=low
    rjmp BitDone
Send1:
    sbi PORTB, PB0 ; send a 1=high
BitDone:
    dec r17 ; bitcnt--
    breq start ; if bitcnt == 0, start over
    rjmp txloop ; else do the next bit


Build, compile and upload it

Nugrohos-MacBook-Air:serial nugroho$ avra -o serialTX.hex serialTX.s 

AVRA: advanced AVR macro assembler Version 1.3.0 Build 1 (8 May 2010)
Copyright (C) 1998-2010. Check out README file for more info

AVRA is an open source assembler for Atmel AVR microcontroller family
It can be used as a replacement of 'AVRASM32.EXE' the original assembler
shipped with AVR Studio. We do not guarantee full compatibility for avra.

AVRA comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of avra under the terms
of the GNU General Public License.
For more information about these matters, see the files named COPYING.

Pass 1...
Pass 2...
done

Used memory blocks:
Code : Start = 0x0000, End = 0x000A, Length = 0x000B

Assembly complete with no errors.
Segment usage:
Code : 11 words (22 bytes)
Data : 0 bytes
EEPROM : 0 bytes
Nugrohos-MacBook-Air:serial nugroho$

Nugrohos-MacBook-Air:serial nugroho$ ls
serialTX.s serialTX.s.eep.hex serialTX.s.obj
serialTX.s.cof serialTX.s.hex serialTX1.s
Nugrohos-MacBook-Air:serial nugroho$ avrdude -p t13 -c usbasp -P usb -B4 -n

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:serial nugroho$ avrdude -p t13 -c usbasp -P usb -B4 -U flash:w:serialTX.s.hex

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: set SCK frequency to 187500 Hz
avrdude: reading input file "serialTX.s.hex"
avrdude: input file serialTX.s.hex auto detected as Intel Hex
avrdude: writing flash (22 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 22 bytes of flash written
avrdude: verifying flash memory against serialTX.s.hex:
avrdude: load data flash data from input file serialTX.s.hex:
avrdude: input file serialTX.s.hex auto detected as Intel Hex
avrdude: input file serialTX.s.hex contains 22 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 22 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:serial nugroho$





I use USB-to-TTL, and after several fail attempt to compile and upload using usbasp, I’m getting annoyed, so I use hc-05 (a bluetooth module) to communicate with ATTiny. Just connect the RX pin to PB0.

Nugrohos-MacBook-Air:serial nugroho$ screen /dev/cu.HC-05-DevB 
avr


modify it 

note that 

L1:     dec  r20
        brne L1

will generate error
Pass 1...
Abort trap: 6

edit it to 
L1:     
        dec  r20
        brne L1

not sure why avra refuse the first formatting

(of course the code above still won't work, it lacks the baud rate :) )


Wednesday, May 20, 2015

ADC on ATTiny13A with PWM Output in Assembler

Yep, here we are. I use pin B3 as ADC input, and B0 as output. The delay's vary; depend on r16 value, which is ADC value. Since the output's in PWM mode, if we connect LED to B0, the brightness is vary too.

.include "../tn13Adef.INC" 

.org $0000 
init:                       ;prescaler 50-200KHz, sys clock 1.2MHz
    ldi   r16,0b11100011    ;[ADEN(ENABLE),ADSC(START),ADATE,ADIF,ADIE,ADPS2,ADPS1,ADPS0]
    out   ADCSRA,r16        ;start adc
    ldi   r16,0b00000011    ;r16 = 3
    out   ADMUX,r16         ;select channel 3 (PORT B3)
    sbi   PORTB,PORTB3      ;enable pullup
    sbi   DDRB,0            ;set PORT B0 as output
main:
    in    r16,ADCL         
    in    r17,ADCH        
    rcall delay          
    sbi   PINB,0         
    rjmp  main

delay: 
    dec r16
    brne delay

    ret


PWM (Pulse-Width Modulation) di AVR memungkinkan output di AVR ATTiny13 berkelakuan seperti analog, dengan resolusi 256 atau, jika dihubungkan ke LED, memiliki 256 tingkat ke-terang-an (redup-terang).

Program diatas menggunakan ADC di port B3 untuk mengontrol tingkat terang-redup LED di port B0



Sunday, May 17, 2015

Reset clock fuse bit on AVR

My ATTiny13A LED’s still blinking, but I can’t program it anymore.



Here's the message

Nugrohos-MacBook-Air:~ nugroho$ avrdude -p t13 -c usbasp -P usb -n

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

Nugrohos-MacBook-Air:~ nugroho$ avrdude -p t13 -c usbasp -P usb -n -F

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000 (retrying)
avrdude: Device signature = 0x000000 (retrying)
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATtiny13 is 1E 90 07

avrdude done. Thank you.

Nugrohos-MacBook-Air:~ nugroho$

It can still be programmed using -B4 option however

Nugrohos-MacBook-Air:~ nugroho$ avrdude -p t13 -c usbasp -P usb -B4 -n  

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:~ nugroho$


From evilmadscientist.com, it apparently my ATTiny clock is slower than my USBASP. We have to erase the chip and reset the clock.

Nugrohos-MacBook-Air:~ nugroho$ avrdude -p t13 -c usbasp -P usb -tuF   

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000 (retrying)
avrdude: Device signature = 0x000000 (retrying)
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATtiny13 is 1E 90 07
avrdude> sck 1000
>>> sck 1000
avrdude: set SCK frequency to 1000 Hz
avrdude> e
>>> e
avrdude: erasing chip
avrdude: error: programm enable: target doesn't answer. 1
avrdude> sck 10
>>> sck 10
avrdude: set SCK frequency to 93750 Hz
avrdude> quit
>>> quit

avrdude done. Thank you.

Nugrohos-MacBook-Air:~ nugroho$ avrdude -p t13 -c usbasp -P usb -n

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

Nugrohos-MacBook-Air:~ nugroho$ avrdude -p t13 -c usbasp -P usb -B4 -n

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:~ nugroho$ avrdude -p t13 -c usbasp -P usb -B4 -tuF

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007
avrdude> sck 1000
>>> sck 1000
avrdude: set SCK frequency to 1000 Hz
avrdude> e
>>> e
avrdude: erasing chip
avrdude: set SCK frequency to 187500 Hz
avrdude> quit
>>> quit

avrdude done. Thank you.

Nugrohos-MacBook-Air:~ nugroho$

Nugrohos-MacBook-Air:~ nugroho$ avrdude -p t13 -c usbasp -P usb -U lfuse:w:0x6A:m -U hfuse:w:0xFF:m -B250



avrdude: set SCK frequency to 4000 Hz

avrdude: AVR device initialized and ready to accept instructions



Reading | ################################################## | 100% 0.03s



avrdude: Device signature = 0x1e9007

avrdude: reading input file "0x6A"

avrdude: writing lfuse (1 bytes):



Writing | ################################################## | 100% 0.01s



avrdude: 1 bytes of lfuse written

avrdude: verifying lfuse memory against 0x6A:

avrdude: load data lfuse data from input file 0x6A:

avrdude: input file 0x6A contains 1 bytes

avrdude: reading on-chip lfuse data:



Reading | ################################################## | 100% 0.01s



avrdude: verifying ...

avrdude: 1 bytes of lfuse verified

avrdude: reading input file "0xFF"

avrdude: writing hfuse (1 bytes):



Writing | ################################################## | 100% 0.01s



avrdude: 1 bytes of hfuse written

avrdude: verifying hfuse memory against 0xFF:

avrdude: load data hfuse data from input file 0xFF:

avrdude: input file 0xFF contains 1 bytes

avrdude: reading on-chip hfuse data:



Reading | ################################################## | 100% 0.01s



avrdude: verifying ...

avrdude: 1 bytes of hfuse verified



avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)



avrdude done. Thank you.



Nugrohos-MacBook-Air:~ nugroho$

...

It’s bit different than on http://www.evilmadscientist.com/2007/fixing-a-bad-frequency-fuse-bit-on-an-avr/ because the Attiny13A clock automatically back to 187500 without manual set.



########


Untuk “menghidupkan” lagi AVR yang bermasalah dengan fuse-bit (mungkin kita tidak sengaja mensetting clock terlalu lambat, lebih lambat dari clock USBASP atau ISP kita sehingga program tidak dapat diupload), kita harus menghapus program yang terupload di AVR.

Gunakan avrdude dalam mode interaktif seperti di atas

Arduino Nano as Programmer to Upgrade USBASP Firmware [Solved]


This post’s for self doc only. Went to work full day, furiously, in front of My Mac, from Saturday morning to about 7 pm because of single line of warning. 

avrdude: warning: cannot set sck period. please check for usbasp firmware update. 

Yeah, maybe it’s not worth my time but still...  

Anyway, I use my arduino Nano as ISP programmer, to upload the new firmware to USBASP.  

On Arduino IDE, open file, example, ArduinoISP. 

Compile it.

Upload arduinoISP sketch to  Nano. 

Connect the pins. 

Arduino Nano — USBASP

5V — 2
GND — 10
13 —  7
12 —  9 (MISO)
11 —  1 (MOSI)
10 —   5 (RESET)

Don’t forget to connect the jumper J2 or JP2 to enable self programming on USBASP. 

Don’t use 2011’s firmware version, use 2009’s instead


I have two example of command, for windows


avrdude -C ../etc/avrdude.conf -c avrisp -P COM3 -b 19200 -p m8 -v
avrdude -C ../etc/avrdude.conf -c avrisp -P COM3 -b 19200 -p m8 -U flash:r:original_firmware.bin:r
avrdude -C ../etc/avrdude.conf -c avrisp -P COM3 -b 19200 -p m8 -U flash:w:original_firmware.bin
avrdude -C ../etc/avrdude.conf -c avrisp -P COM3 -b 19200 -p m8 -U flash:w:c:\usbasp.atmega8.2011-05- 28.hex
and
avrdude -p m8 -b 19200 -c avrisp -P com2 -U flash:r:usbasp.atmega8.hobbyking.hex
avrdude -p m8 -b 19200 -c avrisp -P com2 -U flash:w:usbasp.atmega8.2009-02-28.hex

Have to modify that to satisfy my Mac environment

I’m sure my Mac have no COM port, and my successful avrdude command is like this
avrdude -p attiny13A -P usb -c usbasp -n

avrdude -p t13 -c usbasp -P usb -U flash:w:template.hex

so maybe I have to use -P usb
avrdude  -c avrisp  -P usb -b 19200 -p m8 -v
avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/CrossPack-AVR-20131216/etc/avrdude.conf"
User configuration file is "/Users/nugroho/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : usb
Using Programmer : avrisp
Overriding Baud Rate : 19200
avrdude: ser_open(): can't open device "usb": No such file or directory
avrdude done. Thank you.
Nugrohos-MacBook-Air:firmware nugroho$
#
no
OK
again
Nugrohos-MacBook-Air:firmware nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -v

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/CrossPack-AVR-20131216/etc/avrdude.conf"
User configuration file is "/Users/nugroho/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : avrisp
Overriding Baud Rate : 19200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x15
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x15
AVR Part : ATmega8
Chip Erase delay : 10000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 4 20 128 0 no 512 4 0 9000 9000 0xff 0xff
flash 33 10 64 0 yes 8192 64 128 4500 4500 0xff 0x00
lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : STK500
Description : Atmel AVR ISP

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
Hardware Version: -1597263620
Firmware Version: 3296192.-1597263620
Topcard : STK502
Vtarget : 1.8 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10

avrdude done. Thank you.

Nugrohos-MacBook-Air:firmware nugroho$


avrdude -p m8 -b 19200 -c avrisp -P /dev/cu.wchusbserial1420
-U flash:r:usbasp.atmega8.original.hex

Press reset on Arduino Nano before enter command above
Nugrohos-MacBook-Air:firmware nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -v

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/CrossPack-AVR-20131216/etc/avrdude.conf"
User configuration file is "/Users/nugroho/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : avrisp
Overriding Baud Rate : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
AVR Part : ATmega8
Chip Erase delay : 10000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 4 20 128 0 no 512 4 0 9000 9000 0xff 0xff
flash 33 10 64 0 yes 8192 64 128 4500 4500 0xff 0x00
lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : STK500
Description : Atmel AVR ISP
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

Nugrohos-MacBook-Air:firmware nugroho$

Using -F option
Nugrohos-MacBook-Air:firmware nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -v -F

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/CrossPack-AVR-20131216/etc/avrdude.conf"
User configuration file is "/Users/nugroho/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : avrisp
Overriding Baud Rate : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
AVR Part : ATmega8
Chip Erase delay : 10000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 4 20 128 0 no 512 4 0 9000 9000 0xff 0xff
flash 33 10 64 0 yes 8192 64 128 4500 4500 0xff 0x00
lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : STK500
Description : Atmel AVR ISP
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATmega8 is 1E 93 07
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: Fuses OK (H:FF, E:00, L:00)

avrdude done. Thank you.

Nugrohos-MacBook-Air:firmware nugroho$


Now backup
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -U flash:r:original_firmware.hex:r -F
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATmega8 is 1E 93 07
avrdude: reading flash memory:

Reading | ################################################## | 100% 15.04s

avrdude: writing output file "original_firmware.hex"

avrdude: safemode: Fuses OK (H:FF, E:00, L:00)

avrdude done. Thank you.

Nugrohos-MacBook-Air:attiny13a nugroho$ ls
blinkLED_A coba2 firmware.hex original_firmware.hex usbasp.atmega8.2009-02-28.hex
coba1 coba3 lcdNO tn13Adef.inc
Nugrohos-MacBook-Air:attiny13a nugroho$

And upload new firmware
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -U flash:w:firmware.hex -F
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATmega8 is 1E 93 07
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "firmware.hex"
avrdude: input file firmware.hex auto detected as Intel Hex
avrdude: writing flash (3966 bytes):

Writing | ################################################## | 100% 9.16s

avrdude: 3966 bytes of flash written
avrdude: verifying flash memory against firmware.hex:
avrdude: load data flash data from input file firmware.hex:
avrdude: input file firmware.hex auto detected as Intel Hex
avrdude: input file firmware.hex contains 3966 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 7.29s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x3b
avrdude: verification error; content mismatch

avrdude: safemode: Fuses OK (H:FF, E:00, L:00)

avrdude done. Thank you.

Nugrohos-MacBook-Air:attiny13a nugroho$

try it
Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp -v

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/CrossPack-AVR-20131216/etc/avrdude.conf"
User configuration file is "/Users/nugroho/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : usb
Using Programmer : usbasp
AVR Part : ATtiny13
Chip Erase delay : 4000 us
PAGEL : P00
BS2 : P00
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 5 4 0 no 64 4 0 4000 4000 0xff 0xff
flash 65 6 32 0 yes 1024 32 32 4500 4500 0xff 0xff
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 2 0 0 0 0 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

Programmer Type : usbasp
Description : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007
avrdude: safemode: lfuse reads as 6A
avrdude: safemode: hfuse reads as FF

avrdude: safemode: lfuse reads as 6A
avrdude: safemode: hfuse reads as FF
avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:coba3 nugroho$


Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp -U flash:w:coba3.s.hex

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "coba3.s.hex"
avrdude: input file coba3.s.hex auto detected as Intel Hex
avrdude: writing flash (34 bytes):

Writing | ################################################## | 100% 0.05s

avrdude: 34 bytes of flash written
avrdude: verifying flash memory against coba3.s.hex:
avrdude: load data flash data from input file coba3.s.hex:
avrdude: input file coba3.s.hex auto detected as Intel Hex
avrdude: input file coba3.s.hex contains 34 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 34 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:coba3 nugroho$

try 2011 version

Nugrohos-MacBook-Air:attiny13a nugroho$ ls
blinkLED_A firmware.hex usbasp.atmega8.2009-02-28.hex
coba1 lcdNO usbasp.atmega8.2011-05-28.hex
coba2 original_firmware.hex
coba3 tn13Adef.inc
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -v -F

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/CrossPack-AVR-20131216/etc/avrdude.conf"
User configuration file is "/Users/nugroho/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.wchusbserial1420
Using Programmer : avrisp
Overriding Baud Rate : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
AVR Part : ATmega8
Chip Erase delay : 10000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 4 20 128 0 no 512 4 0 9000 9000 0xff 0xff
flash 33 10 64 0 yes 8192 64 128 4500 4500 0xff 0x00
lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : STK500
Description : Atmel AVR ISP
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x1e9307
avrdude: safemode: lfuse reads as 9F
avrdude: safemode: hfuse reads as D9

avrdude: safemode: lfuse reads as 9F
avrdude: safemode: hfuse reads as D9
avrdude: safemode: Fuses OK (H:FF, E:D9, L:9F)

avrdude done. Thank you.

Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -U flash:w: -F
.DS_Store coba3/ tn13Adef.inc
blinkLED_A/ firmware.hex usbasp.atmega8.2009-02-28.hex
coba1/ lcdNO/ usbasp.atmega8.2011-05-28.hex
coba2/ original_firmware.hex
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -U flash:w:usbasp.atmega8.2011-05-28.hex -F
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x1e9307
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "usbasp.atmega8.2011-05-28.hex"
avrdude: input file usbasp.atmega8.2011-05-28.hex auto detected as Intel Hex
avrdude: writing flash (4700 bytes):

Writing | ################################################## | 100% 10.94s

avrdude: 4700 bytes of flash written
avrdude: verifying flash memory against usbasp.atmega8.2011-05-28.hex:
avrdude: load data flash data from input file usbasp.atmega8.2011-05-28.hex:
avrdude: input file usbasp.atmega8.2011-05-28.hex auto detected as Intel Hex
avrdude: input file usbasp.atmega8.2011-05-28.hex contains 4700 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 8.70s

avrdude: verifying ...
avrdude: 4700 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:D9, L:9F)

avrdude done. Thank you.

Nugrohos-MacBook-Air:attiny13a nugroho$

It's way promising
Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp -n

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp -P usb

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

not
go to original 2009 version
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -U flash:w:usbasp.atmega8.20 -F
usbasp.atmega8.2009-02-28.hex usbasp.atmega8.2011-05-28.hex
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -U flash:w:usbasp.atmega8.2009-02-28.hex -F
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x1e9307
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "usbasp.atmega8.2009-02-28.hex"
avrdude: input file usbasp.atmega8.2009-02-28.hex auto detected as Intel Hex
avrdude: writing flash (3826 bytes):

Writing | ################################################## | 100% 8.86s

avrdude: 3826 bytes of flash written
avrdude: verifying flash memory against usbasp.atmega8.2009-02-28.hex:
avrdude: load data flash data from input file usbasp.atmega8.2009-02-28.hex:
avrdude: input file usbasp.atmega8.2009-02-28.hex auto detected as Intel Hex
avrdude: input file usbasp.atmega8.2009-02-28.hex contains 3826 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 7.05s

avrdude: verifying ...
avrdude: 3826 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:D9, L:9F)

avrdude done. Thank you.

Nugrohos-MacBook-Air:attiny13a nugroho$
Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

Nugrohos-MacBook-Air:coba3 nugroho$

back to patched 2009 version
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -U flash:w:firmware.hex -F
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x1e9307
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "firmware.hex"
avrdude: input file firmware.hex auto detected as Intel Hex
avrdude: writing flash (3966 bytes):

Writing | ################################################## | 100% 9.16s

avrdude: 3966 bytes of flash written
avrdude: verifying flash memory against firmware.hex:
avrdude: load data flash data from input file firmware.hex:
avrdude: input file firmware.hex auto detected as Intel Hex
avrdude: input file firmware.hex contains 3966 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 7.29s

avrdude: verifying ...
avrdude: 3966 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:D9, L:9F)

avrdude done. Thank you.

Nugrohos-MacBook-Air:attiny13a nugroho$

Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

trying to upload using arduino nano as isp to ATTiny13A
Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c avrisp -P /dev/cu.wchusbserial1420 
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
^C
.

hm, maybe the ATTiny’s broken

here the -v -vv and -vvv

Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp -v

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/CrossPack-AVR-20131216/etc/avrdude.conf"
User configuration file is "/Users/nugroho/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : usb
Using Programmer : usbasp
AVR Part : ATtiny13
Chip Erase delay : 4000 us
PAGEL : P00
BS2 : P00
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 5 4 0 no 64 4 0 4000 4000 0xff 0xff
flash 65 6 32 0 yes 1024 32 32 4500 4500 0xff 0xff
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 2 0 0 0 0 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

Programmer Type : usbasp
Description : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp -vv

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/CrossPack-AVR-20131216/etc/avrdude.conf"
User configuration file is "/Users/nugroho/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : usb
Using Programmer : usbasp
avrdude: seen device from vendor ->www.fischl.de<- data-blogger-escaped--="" data-blogger-escaped-avrdude:="" data-blogger-escaped-product="" data-blogger-escaped-seen="">USBasp<- data-blogger-escaped------------="" data-blogger-escaped----------="" data-blogger-escaped-------="" data-blogger-escaped------="" data-blogger-escaped-----="" data-blogger-escaped--="" data-blogger-escaped--c="" data-blogger-escaped--f="" data-blogger-escaped--p="" data-blogger-escaped--vvv="" data-blogger-escaped-0="" data-blogger-escaped-0x00="" data-blogger-escaped-0x53="" data-blogger-escaped-0xff="" data-blogger-escaped-100="" data-blogger-escaped-1024="" data-blogger-escaped-16="" data-blogger-escaped-17:26:24="" data-blogger-escaped-1="" data-blogger-escaped-2000-2005="" data-blogger-escaped-2007-2009="" data-blogger-escaped-200="" data-blogger-escaped-2013="" data-blogger-escaped-25="" data-blogger-escaped-2="" data-blogger-escaped-32="" data-blogger-escaped-3="" data-blogger-escaped-4000="" data-blogger-escaped-4500="" data-blogger-escaped-4="" data-blogger-escaped-5="" data-blogger-escaped-6.0.1="" data-blogger-escaped-64="" data-blogger-escaped-65="" data-blogger-escaped-6="" data-blogger-escaped-:="" data-blogger-escaped-a="" data-blogger-escaped-again="" data-blogger-escaped-ages="" data-blogger-escaped-and="" data-blogger-escaped-answer.="" data-blogger-escaped-at="" data-blogger-escaped-attiny13="" data-blogger-escaped-auto="" data-blogger-escaped-avr="" data-blogger-escaped-avrdude.conf="" data-blogger-escaped-avrdude:="" data-blogger-escaped-avrdude="" data-blogger-escaped-avrduderc="" data-blogger-escaped-because="" data-blogger-escaped-block="" data-blogger-escaped-brian="" data-blogger-escaped-bs2="" data-blogger-escaped-bytedelay="" data-blogger-escaped-c="" data-blogger-escaped-calibration="" data-blogger-escaped-check.="" data-blogger-escaped-check="" data-blogger-escaped-chip="" data-blogger-escaped-cmdexedelay="" data-blogger-escaped-compiled="" data-blogger-escaped-configuration="" data-blogger-escaped-connections="" data-blogger-escaped-copyright="" data-blogger-escaped-dean="" data-blogger-escaped-dec="" data-blogger-escaped-dedicated="" data-blogger-escaped-delay="" data-blogger-escaped-description="" data-blogger-escaped-detail="" data-blogger-escaped-device="" data-blogger-escaped-disposition="" data-blogger-escaped-does="" data-blogger-escaped-doesn="" data-blogger-escaped-done.="" data-blogger-escaped-double="" data-blogger-escaped-eeprom="" data-blogger-escaped-enable:="" data-blogger-escaped-equals="" data-blogger-escaped-erase="" data-blogger-escaped-error:="" data-blogger-escaped-etc="" data-blogger-escaped-exist="" data-blogger-escaped-failed="" data-blogger-escaped-file="" data-blogger-escaped-flash="" data-blogger-escaped-from="" data-blogger-escaped-given="" data-blogger-escaped-hfuse="" data-blogger-escaped-http:="" data-blogger-escaped-indx="" data-blogger-escaped-initialization="" data-blogger-escaped-is="" data-blogger-escaped-joerg="" data-blogger-escaped-lfuse="" data-blogger-escaped-local="" data-blogger-escaped-lock="" data-blogger-escaped-maxw="" data-blogger-escaped-memory="" data-blogger-escaped-minw="" data-blogger-escaped-mode="" data-blogger-escaped-no="" data-blogger-escaped-not="" data-blogger-escaped-nugroho="" data-blogger-escaped-nugrohos-macbook-air:coba3="" data-blogger-escaped-null="" data-blogger-escaped-on="" data-blogger-escaped-or="" data-blogger-escaped-override="" data-blogger-escaped-p00="" data-blogger-escaped-page="" data-blogger-escaped-paged="" data-blogger-escaped-pagel="" data-blogger-escaped-parallel="" data-blogger-escaped-part="" data-blogger-escaped-period="" data-blogger-escaped-poll="" data-blogger-escaped-polled="" data-blogger-escaped-pollindex="" data-blogger-escaped-pollvalue="" data-blogger-escaped-port="" data-blogger-escaped-program="" data-blogger-escaped-programm="" data-blogger-escaped-programmer="" data-blogger-escaped-pulse="" data-blogger-escaped-rc="-1" data-blogger-escaped-readback="" data-blogger-escaped-regular="" data-blogger-escaped-reset="" data-blogger-escaped-retry="" data-blogger-escaped-rosspack-avr-20131216="" data-blogger-escaped-sck="" data-blogger-escaped-seen="" data-blogger-escaped-serial="" data-blogger-escaped-sers="" data-blogger-escaped-set="" data-blogger-escaped-signature="" data-blogger-escaped-size="" data-blogger-escaped-skipping="" data-blogger-escaped-stabdelay="" data-blogger-escaped-syncloops="" data-blogger-escaped-system="" data-blogger-escaped-t13="" data-blogger-escaped-t="" data-blogger-escaped-target="" data-blogger-escaped-thank="" data-blogger-escaped-this="" data-blogger-escaped-timeout="" data-blogger-escaped-to="" data-blogger-escaped-try="" data-blogger-escaped-type="" data-blogger-escaped-us="" data-blogger-escaped-usb="" data-blogger-escaped-usbasp="" data-blogger-escaped-usbasp_open="" data-blogger-escaped-use="" data-blogger-escaped-user="" data-blogger-escaped-using="" data-blogger-escaped-usr="" data-blogger-escaped-vendor="" data-blogger-escaped-version="" data-blogger-escaped-wide="" data-blogger-escaped-wunsch="" data-blogger-escaped-www.bdmicro.com="" data-blogger-escaped-www.fischl.de="" data-blogger-escaped-yes="" data-blogger-escaped-you.="">www.fischl.de<- data-blogger-escaped--="" data-blogger-escaped-avrdude:="" data-blogger-escaped-product="" data-blogger-escaped-seen="">USBasp<- data-blogger-escaped------------="" data-blogger-escaped----------="" data-blogger-escaped-------="" data-blogger-escaped------="" data-blogger-escaped-----="" data-blogger-escaped-0.00savrdude:="" data-blogger-escaped-0="" data-blogger-escaped-0x00="" data-blogger-escaped-0x53="" data-blogger-escaped-0xff="" data-blogger-escaped-100="" data-blogger-escaped-1024="" data-blogger-escaped-1="" data-blogger-escaped-200="" data-blogger-escaped-25="" data-blogger-escaped-2="" data-blogger-escaped-32="" data-blogger-escaped-3="" data-blogger-escaped-4000="" data-blogger-escaped-4500="" data-blogger-escaped-4="" data-blogger-escaped-5="" data-blogger-escaped-64="" data-blogger-escaped-65="" data-blogger-escaped-6="" data-blogger-escaped-:="" data-blogger-escaped-accept="" data-blogger-escaped-ages="" data-blogger-escaped-and="" data-blogger-escaped-attiny13="" data-blogger-escaped-auto="" data-blogger-escaped-avr="" data-blogger-escaped-avrdude:="" data-blogger-escaped-because="" data-blogger-escaped-block="" data-blogger-escaped-bs2="" data-blogger-escaped-bytedelay="" data-blogger-escaped-calibration="" data-blogger-escaped-chip="" data-blogger-escaped-cmdexedelay="" data-blogger-escaped-dedicated="" data-blogger-escaped-delay="" data-blogger-escaped-description="" data-blogger-escaped-detail="" data-blogger-escaped-device="" data-blogger-escaped-disposition="" data-blogger-escaped-eeprom="" data-blogger-escaped-equals="" data-blogger-escaped-erase="" data-blogger-escaped-flash="" data-blogger-escaped-given="" data-blogger-escaped-hfuse="" data-blogger-escaped-http:="" data-blogger-escaped-indx="" data-blogger-escaped-initialized="" data-blogger-escaped-instructions="" data-blogger-escaped-lfuse="" data-blogger-escaped-lock="" data-blogger-escaped-maxw="" data-blogger-escaped-memory="" data-blogger-escaped-minw="" data-blogger-escaped-mode="" data-blogger-escaped-no="" data-blogger-escaped-null="" data-blogger-escaped-p00="" data-blogger-escaped-page="" data-blogger-escaped-paged="" data-blogger-escaped-pagel="" data-blogger-escaped-parallel="" data-blogger-escaped-part="" data-blogger-escaped-period="" data-blogger-escaped-poll="" data-blogger-escaped-polled="" data-blogger-escaped-pollindex="" data-blogger-escaped-pollvalue="" data-blogger-escaped-program="" data-blogger-escaped-programmer="" data-blogger-escaped-pulse="" data-blogger-escaped-readback="" data-blogger-escaped-reading="" data-blogger-escaped-ready="" data-blogger-escaped-reset="" data-blogger-escaped-retry="" data-blogger-escaped-sck="" data-blogger-escaped-serial="" data-blogger-escaped-set="" data-blogger-escaped-signature="" data-blogger-escaped-size="" data-blogger-escaped-stabdelay="" data-blogger-escaped-syncloops="" data-blogger-escaped-timeout="" data-blogger-escaped-to="" data-blogger-escaped-type="" data-blogger-escaped-us="" data-blogger-escaped-usbasp="" data-blogger-escaped-usbasp_cpi_cmd="" data-blogger-escaped-usbasp_initialize="" data-blogger-escaped-usbasp_program_enable="" data-blogger-escaped-usbasp_spi_set_sck_period="" data-blogger-escaped-www.fischl.de="" data-blogger-escaped-x30="" data-blogger-escaped-yes=""> 0x01, 0x31, 0x01, 0x01
avrdude: usbasp_cpi_cmd(0x30, 0x00, 0x01, 0x00) => 0x00, 0x31, 0x00, 0x01
Reading | ################# | 33% 0.00savrdude: usbasp_cpi_cmd(0x30, 0x00, 0x02, 0x00) => 0x00, 0x61, 0x00, 0x03
Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x010103
avrdude: Expected signature for ATtiny13 is 1E 90 07
Double check chip, or use -F to override this check.
avrdude: usbasp_close()

avrdude done. Thank you.

Nugrohos-MacBook-Air:coba3 nugroho$

Search the forums, its like the culprit is auto set sck on the new firmare. (http://openrcforums.com/forum/viewtopic.php?f=10&t=1363#p29615)
avrdude: auto set sck period (because given equals null)
got
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m8 -c avrisp -b 19200 -P /dev/cu.wchusbserial1420 -U flash:w:main.hex -F
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.12s

avrdude: Device signature = 0x1e9307
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (3758 bytes):

Writing | ################################################## | 100% 8.72s

avrdude: 3758 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 3758 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 6.93s

avrdude: verifying ...
avrdude: 3758 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:D9, L:9F)

avrdude done. Thank you.

Nugrohos-MacBook-Air:attiny13a nugroho$


no
uh, I don’t want to be back to old locked firmware. The forum suggest that i have to jumper four resistor
curious
connect it to my arduino pro mini
and voila…
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m328 -c usbasp -P usb -n   

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: Expected signature for ATmega328 is 1E 95 14
Double check chip, or use -F to override this check.

avrdude done. Thank you.
Nugrohos-MacBook-Air:attiny13a nugroho$ avrdude -p m328 -c usbasp -P usb -b 1920 -U flash:r:ArProMini.bin:r -v -F



avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24

Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

Copyright (c) 2007-2009 Joerg Wunsch



System wide configuration file is "/usr/local/CrossPack-AVR-20131216/etc/avrdude.conf"

User configuration file is "/Users/nugroho/.avrduderc"

User configuration file does not exist or is not a regular file, skipping



Using Port : usb

Using Programmer : usbasp

Overriding Baud Rate : 1920

AVR Part : ATmega328

Chip Erase delay : 9000 us

PAGEL : PD7

BS2 : PC2

RESET disposition : dedicated

RETRY pulse : SCK

serial program mode : yes

parallel program mode : yes

Timeout : 200

StabDelay : 100

CmdexeDelay : 25

SyncLoops : 32

ByteDelay : 0

PollIndex : 3

PollValue : 0x53

Memory Detail :



Block Poll Page Polled

Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack

----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------

eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff

flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff

lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00

calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00

signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00



Programmer Type : usbasp

Description : USBasp, http://www.fischl.de/usbasp/



avrdude: auto set sck period (because given equals null)

avrdude: AVR device initialized and ready to accept instructions



Reading | ################################################## | 100% 0.00s



avrdude: Device signature = 0x1e950f

avrdude: Expected signature for ATmega328 is 1E 95 14

avrdude: safemode: lfuse reads as FF

avrdude: safemode: hfuse reads as DA

avrdude: safemode: efuse reads as 5

avrdude: reading flash memory:



Reading | ################################################## | 100% 8.43s



avrdude: writing output file "ArProMini.bin"



avrdude: safemode: lfuse reads as FF

avrdude: safemode: hfuse reads as DA

avrdude: safemode: efuse reads as 5

avrdude: safemode: Fuses OK (H:05, E:DA, L:FF)



avrdude done. Thank you.



Nugrohos-MacBook-Air:attiny13a nugroho$ ls -l

total 232

-rw-r--r-- 1 nugroho staff 32670 May 16 17:52 ArProMini.bin

drwxr-xr-x 8 nugroho staff 272 May 15 21:50 blinkLED_A

drwxr-xr-x 8 nugroho staff 272 May 16 00:30 coba1

drwxr-xr-x 8 nugroho staff 272 May 15 21:50 coba2

drwxr-xr-x 8 nugroho staff 272 May 16 09:16 coba3

-rw-r--r--@ 1 nugroho staff 11182 May 16 13:29 firmware.hex

drwxr-xr-x 4 nugroho staff 136 May 15 21:50 lcdNO

-rw-r--r--@ 1 nugroho staff 10597 May 16 15:19 main.hex

-rw-r--r-- 1 nugroho staff 8192 May 16 15:27 original_firmware.bin

-rw-r--r-- 1 nugroho staff 8192 May 16 13:42 original_firmware.hex

-rw-r--r-- 1 nugroho staff 15784 May 11 23:23 tn13Adef.inc

-rw-r--r--@ 1 nugroho staff 10785 Feb 28 2009 usbasp.atmega8.2009-02-28.hex

-rw-r--r--@ 1 nugroho staff 13248 May 16 14:05 usbasp.atmega8.2011-05-28.hex

Nugrohos-MacBook-Air:attiny13a nugroho$


its very weird and then
ugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp -P usb -n -F

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000 (retrying)
avrdude: Device signature = 0x000000 (retrying)
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATtiny13 is 1E 90 07

avrdude done. Thank you.

Nugrohos-MacBook-Air:coba3 nugroho$

sigh, my usbasp is ok
On the bright side: the update firmware warning is gone, using main.hex, a self compiled 2009 firmware
######
wait, ….
found another solution from http://forum.arduino.cc/index.php?topic=262150.0 and http://forum.arduino.cc/index.php?topic=282330.0
Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp -B4 -n 

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:coba3 nugroho$

Nugrohos-MacBook-Air:coba3 nugroho$ avrdude -p t13 -c usbasp -P usb -B4 -U flash:w:coba3.s.hex

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: set SCK frequency to 187500 Hz
avrdude: reading input file "coba3.s.hex"
avrdude: input file coba3.s.hex auto detected as Intel Hex
avrdude: writing flash (34 bytes):

Writing | ################################################## | 100% 0.04s

avrdude: 34 bytes of flash written
avrdude: verifying flash memory against coba3.s.hex:
avrdude: load data flash data from input file coba3.s.hex:
avrdude: input file coba3.s.hex auto detected as Intel Hex
avrdude: input file coba3.s.hex contains 34 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 34 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:coba3 nugroho$

.
the coba.s is PB0, PB1, PB2 is connected to LED each. PB0 and PB is always on whilst PB2 blink every 1s.

.include "../tn13Adef.inc"
.org 0                         

init:
    ldi r16,0b00000111         
    out DDRB,r16                ; PB2 as output
    sbi PORTB,1
    sbi PORTB,0
loop:
    sbi PORTB,2                 
    rcall timer                 
    cbi PORTB,2                 
    rcall timer                
    rjmp loop

timer:
    ldi r16,0                   ; these are timer counters
    ldi r17,0
    ldi r18,5

timer2:
    inc r16                     ; do 256 iterations
    brne timer2
    inc r17                     ; do 256 times
    brne timer2
    dec r18
    brne timer2                 ; do 5 times
    ret                         ; return



for me it’s enough for this day,

.
.
.
Actually, not enough (still want to fiddling with the Tiny :p )




Saturday, May 16, 2015

Blinking LED in ATtiny13A in Assembler


After read the ATtiny13A datasheet, I use the code below as the base. Under OS X in my Macbook Air. Using USBASP programmer. 

.include "../tn13Adef.inc"
;Pin assignments
;.equ LED = PB0 ;pin 5 of ATtiny13
.cseg
.org 0x00
rjmp setup
setup:
;CONFIGURE I/O PINS
ldi r16, (1 << PB0)
out PORTB, r16
out DDRB, r16
loop:
rjmp loop

Compile, build and upload it



Last login: Wed May 13 22:50:32 on ttys000

Nugrohos-MacBook-Air:~ nugroho$ avrdude -p t13 -P usb -c usbasp -n

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:~ nugroho$


Nugrohos-MacBook-Air:coba1 nugroho$ avrdude -p t13 -c usbasp -P usb -U flash:w:coba.hex

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "coba.hex"
avrdude: input file coba.hex auto detected as Intel Hex
avrdude: writing flash (10 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 10 bytes of flash written
avrdude: verifying flash memory against coba.hex:
avrdude: load data flash data from input file coba.hex:
avrdude: input file coba.hex auto detected as Intel Hex
avrdude: input file coba.hex contains 10 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 10 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:coba1 nugroho$

Trying to get slightly advanced template 

.nolist
.include "../tn13Adef.inc"
.list

;.def rmp = r16

.dseg
.org 0x0060

.cseg
.org $0000
rjmp main;reset vector
reti;int vector 1
reti;int vector2
reti;...
reti
reti
reti
reti
reti
reti
main:
;init stack
ldi r16, low(ramend)
out spl, r16

;init portb
ldi r16,(1<<ddb2)|(1<<ddb1)|(1<<ddb0)
out ddrb, r16
;rutin
ldi r16, 1<<SE;enable sleep
out mcucr, r16
sei

loop:
sleep;goto sleep
nop;dummy wakeup
rjmp loop

compile, build and upload it


Nugrohos-MacBook-Air:coba2 nugroho$ ls
template.s template.s.eep.hex template.s.obj
template.s.cof template.s.hex
Nugrohos-MacBook-Air:coba2 nugroho$ avra -o template.hex template.s
AVRA: advanced AVR macro assembler Version 1.3.0 Build 1 (8 May 2010)
Copyright (C) 1998-2010. Check out README file for more info

AVRA is an open source assembler for Atmel AVR microcontroller family
It can be used as a replacement of 'AVRASM32.EXE' the original assembler
shipped with AVR Studio. We do not guarantee full compatibility for avra.

AVRA comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of avra under the terms
of the GNU General Public License.
For more information about these matters, see the files named COPYING.

Pass 1...
Pass 2...
done

Used memory blocks:
Code : Start = 0x0000, End = 0x0013, Length = 0x0014

Assembly complete with no errors.
Segment usage:
Code : 20 words (40 bytes)
Data : 0 bytes
EEPROM : 0 bytes
Nugrohos-MacBook-Air:coba2 nugroho$ ls
template.s template.s.eep.hex template.s.obj
template.s.cof template.s.hex

Nugrohos-MacBook-Air:coba2 nugroho$ avrdude -p t13 -c usbasp -P usb -U flash:w:template.s.hex

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "template.s.hex"
avrdude: input file template.s.hex auto detected as Intel Hex
avrdude: writing flash (40 bytes):

Writing | ################################################## | 100% 0.05s

avrdude: 40 bytes of flash written
avrdude: verifying flash memory against template.s.hex:
avrdude: load data flash data from input file template.s.hex:
avrdude: input file template.s.hex auto detected as Intel Hex
avrdude: input file template.s.hex contains 40 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 40 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:coba2 nugroho$

.
Two codes above have no loop feature, the first code just turning LED connected to PortB0 on. No blink. The second turning LED on on PB0 PB1 and PB2

Try to update the first code to turning on LED connected to PB0, PB1 and PB2

.include "../tn13Adef.inc"
;Pin assignments
;.equ LED = PB0 ;pin 5 of ATtiny13
.cseg
.org 0x00
rjmp setup
setup:
;CONFIGURE I/O PINS
ldi r16, (1 << PB0)|(1 << PB1)|(1<<PB2)
out PORTB, r16
out DDRB, r16
loop:
rjmp loop

and try to disassembly it 


Nugrohos-MacBook-Air:coba1 nugroho$ vavrdisasm coba.s.hex 
0: c0 00 rjmp .+0 ; 0x2
2: e0 07 ldi R16, 0x07
4: bb 08 out $18, R16
6: bb 07 out $17, R16
8: cf ff rjmp .-2 ; 0x8
Nugrohos-MacBook-Air:coba1 nugroho$
.
very pretty, :)

Now, how about blinking it?

Just add timer subroutine


.include "../tn13Adef.inc"
;Pin assignments
;.equ LED = PB0 ;pin 5 of ATtiny13
.cseg
.org 0x00
rjmp setup
setup:
;CONFIGURE I/O PINS
ldi r16, (1 << PB0)|(1 << PB1)|(1<<PB2)
out PORTB, r16
out DDRB, r16
loop:
    sbis PORTB,0
    rjmp ledOn
    rjmp ledOff
    
    rally:
    rcall timer
    rjmp loop

timer:
    ldi r17,0x00
    testtimer:
        cpi r17,0xf0
        brsh endtimer   ;branch if same or higher
        ldi r18,0x00
        testtimer2:
            cpi r18,0xf0
            brsh endtimer2 
            inc r18
            rjmp testtimer2
        endtimer2:
        inc r17
        rjmp testtimer
    endtimer:
ret
    
ledOn:
    sbi PORTB,0
    rjmp rally
ledOff:
    cbi PORTB,0
    rjmp rally


compile, build, disassembly it (it’s not necessary; just for fun :) ), and then upload it


Nugrohos-MacBook-Air:coba1 nugroho$ avra -o coba.hex coba.s
AVRA: advanced AVR macro assembler Version 1.3.0 Build 1 (8 May 2010)
Copyright (C) 1998-2010. Check out README file for more info

AVRA is an open source assembler for Atmel AVR microcontroller family
It can be used as a replacement of 'AVRASM32.EXE' the original assembler
shipped with AVR Studio. We do not guarantee full compatibility for avra.

AVRA comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of avra under the terms
of the GNU General Public License.
For more information about these matters, see the files named COPYING.

Pass 1...
Pass 2...
done

Used memory blocks:
Code : Start = 0x0000, End = 0x000B, Length = 0x000C

Assembly complete with no errors.
Segment usage:
Code : 12 words (24 bytes)
Data : 0 bytes
EEPROM : 0 bytes
Nugrohos-MacBook-Air:coba1 nugroho$ vavrdisasm coba.s.hex
0: c0 00 rjmp .+0 ; 0x2
2: e0 07 ldi R16, 0x07
4: bb 08 out $18, R16
6: bb 07 out $17, R16
8: d0 01 rcall .+2 ; 0xc
a: cf fe rjmp .-4 ; 0x8
c: e0 10 ldi R17, 0x00
e: 3f 10 cpi R17, 0xf0
10: f4 10 brcc .+4 ; 0x16
12: 95 13 inc R17
14: cf fc rjmp .-8 ; 0xe
16: 95 08 ret
Nugrohos-MacBook-Air:coba1 nugroho$ avrdude -p t13 -c usbasp -P usb -U flash:w:coba.s.hex

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "coba.s.hex"
avrdude: input file coba.s.hex auto detected as Intel Hex
avrdude: writing flash (24 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 24 bytes of flash written
avrdude: verifying flash memory against coba.s.hex:
avrdude: load data flash data from input file coba.s.hex:
avrdude: input file coba.s.hex auto detected as Intel Hex
avrdude: input file coba.s.hex contains 24 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 24 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:FF, L:6A)

avrdude done. Thank you.

Nugrohos-MacBook-Air:coba1 nugroho$

The timer's maybe little weird, just my approach to delay by make r17 and r18 to count several time. The code below is tidier timer, :)

.include "../tn13Adef.inc"
.org 0                         

init:
    ldi r16,0b00000100         
    out DDRB,r16                ; PB2 as output

loop:
    sbi PORTB,2                 
    rcall timer                 
    cbi PORTB,2                 
    rcall timer                
    rjmp loop

timer:
    ldi r16,0                   ; these are timer counters
    ldi r17,0
    ldi r18,5

timer2:
    inc r16                     ; do 256 iterations
    brne timer2
    inc r17                     ; do 256 times
    brne timer2
    dec r18
    brne timer2                 ; do 5 times
    ret                         ; return



I love assembler, :)





Kode pertama di atas digunakan untuk menyalakan LED di PortB,0 di ATTiny13A. Kode kedua digunakan untuk menyalakan LED di Pin B0, B1 dan B2.

Kode ketiga menggunakan pola/gaya yang sama dengan kode pertama namun yang dinyalakan kali ini adalah LED di Pin B0, B1 dan B2

Ketiga kode di atas hanya digunakan untuk menyalakan LED sekali saja dan terus menyala, memang ada loop tapi loop tersebut tidak melakukan apapun. 

Untuk membuat led berkedip dalam selang waktu tertentu, kita tambahkan subrutin yang bertindak sebagai time. Bagi saya  agak rumit untuk membuat timer di assembler. Saya belum bisa menggunakan model interrupt, sehingga  saya pakai model loop dengan menyuruh r17 dan r18 berhitung dari 0 sampai f0. Juga tambahkan toggle agar jika led nyala maka dia mati dan sebaliknya


323f (5) amp (1) android (12) apple (7) arduino (18) art (1) assembler (21) astina (4) ATTiny (23) blackberry (4) camera (3) canon (2) cerita (2) computer (106) crazyness (11) debian (1) delphi (39) diary (286) flash (8) fortran (6) freebsd (6) google apps script (8) guitar (2) HTML5 (10) IFTTT (7) Instagram (7) internet (12) iOS (5) iPad (6) iPhone (5) java (1) javascript (1) keynote (2) LaTeX (6) lazarus (1) linux (29) lion (15) mac (28) macbook air (8) macbook pro (3) macOS (1) Math (3) mathematica (1) maverick (6) mazda (4) microcontroler (35) mountain lion (2) music (37) netbook (1) nugnux (6) os x (36) php (1) Physicist (29) Picture (3) programming (189) Python (109) S2 (13) software (7) Soliloquy (125) Ubuntu (5) unix (4) Video (8) wayang (3) yosemite (3)