Nugroho's blog.

Monday, May 25, 2015

Android Studio on My OS X Yosemite


Well, a picture is worth thousand words.

So, here the millions words for you, :)
































Previously I went to Android website to install Eclipse with ADT. I installed this Android Studio instead; on my Macbook Air wit OS X Yosemite. 

Oh yeah, you maybe encountered the error about JDK 7. I have to manually point to my JDK 7 installation.

My FreeBSD Installation LeftOver


Didn't really remember the chronology. It use Parallel Desktop. It use VirtualBox too.



















Tak ada yang berbeda antara FreeBSD ini dengan yang lain, jika telah terbiasa dengan Linux atau Unix lain, bahkan Apple OS X, maka kita dapat melihat bahwa Beastie ini (nama logo BSD) sama dengan semua sistem itu. 

The Rock Solid UNIX. :)


Friday, May 22, 2015

Buttered Black Coffee


   
Alfa suka teh mentega kambing gunung.
Penasaran, tapi gak suka teh, dan meski bukan yak, di sini ada banyak kambing, tapi gak ada mentega dari susu kambing. 

Jadi, teh diganti kopi, dan mentega nak diganti dengan mentega roti. 

Enak, bagiku, tapi tidak kusarankan tuk meniru. 

Aku yakin po cha tidak seperti ini. 

:)



.

Thursday, May 21, 2015

Serial Communication at ATTiny13A (#3)

Since we need to set the baud rate. We have to use either manual delay or timer interrupt.

For now, I am trying using manual delay.



Check whether the Pin B0 is blinking using this code

.include "../tn13Adef.inc"
.cseg
.org 0x00
ldi r16, 0b00000001
out ddrb,r16
loop:
ldi r17,0xff
ldi r18,0xff
sbi PORTB,0
rcall delay
cbi PORTB,0
rcall delay
rjmp loop
delay:
dec r17
brne delay
dec r18
brne delay
ret




yup, it is





Serial Communication at ATTiny13A (#2)


To send  bit data, we need 10 bit.

0(start)-8bit-1(stop) so r17 now has value 10


.include "../tn13Adef.inc" 
.cseg
.org 0x00
rjmp start 

start:
    ldi r16, 0x6D 
    ldi r17, 10 
shiftData:
    cpi r17, 10 
    breq low 
    cpi r17, 1
    breq high
    lsr r16
    brcs high
low:
    cbi PORTB, PB0 
    rjmp sent
high:
    sbi PORTB, PB0 
sent:
    dec r17 
    breq start 
    rjmp shiftData 


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 = 0x000E, Length = 0x000F

Assembly complete with no errors.
Segment usage:
Code : 15 words (30 bytes)
Data : 0 bytes
EEPROM : 0 bytes
Nugrohos-MacBook-Air:serial nugroho$ vavrdisasm serialTX.s.hex
0: c0 00 rjmp .+0 ; 0x2
2: e6 0d ldi R16, 0x6d
4: e0 1a ldi R17, 0x0a
6: 30 1a cpi R17, 0x0a
8: f0 21 breq .+8 ; 0x12
a: 30 10 cpi R17, 0x00
c: f0 11 breq .+4 ; 0x12
e: 95 06 lsr R16
10: f0 10 brcs .+4 ; 0x16
12: 98 c0 cbi $18, 0
14: c0 01 rjmp .+2 ; 0x18
16: 9a c0 sbi $18, 0
18: 95 1a dec R17
1a: f3 99 breq .-26 ; 0x2
1c: cf f4 rjmp .-24 ; 0x6
Nugrohos-MacBook-Air:serial nugroho$

.

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 :) )


Akhirnya ...


Ujian pertama KBK Elektronika dan Instrumentasi Fisika
Sangat langka memang, dan dapat hadiah uang dari P Samsul, :) 





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)