Timer Time: Using Internal ATTiny13A Chip’s Timer, "OVF" Interrupt Mode (slightly modified)
We could speeding the timer by pre-loading TCNT0 with a value between 0 and 255, so TCNT0’ll start count at our own value instead of zero. We have to pre-load the TCNT0 at the init subroutine, and pre-load again after flag is set, so we write the command at the timer subroutine. So, our code now will look like this .include "../tn13Adef.inc" .def a=r16 .org 0000 rjmp init .org 0003 rjmp timer init: sbi ddrb,0 ; pin b0 output ldi a,0b00000101 ; prescaler 1024 out TCCR0B,a ldi a,0b00000010 ; enable OVF out TIMSK0,a ldi a, 64 ; preload TCNT0 out TCNT0,a sei ; enable interrupts globally main: rjmp main timer: sbi pinb,0 ; flip pin B0 bit ldi a,64 ; preload again out TCNT0,a reti
Timer Time: Using Internal ATTiny13A Chip’s Timer, "OVF" Interrupt Mode
Using interrupt, we have a subroutine that regularly called, automatically. It called when overflow flag (OVF) is set. As always, the timer/counter (TCNT0 register) counts up from zero toward 255, called an interrupt and rolls over back to zero and starts counts up again. We could set the output at the interrupt subroutine so we eventually have nothing to do at the main program. main: rjmp main
Timer Time: Using Internal ATTiny13A Chip’s Timer “CTC” Mode
Clear Timer on Compare (CTC) as its name suggests, will clear the flag if counter has same value with compare value. Thus, TCNT0 still count fram zero to 255, but if we set OCR0A on 64, timer will clear the flag at 64, restart counter to zero and count up again. If we set OCR0A to 255, then it’ll behave like normal timer in 'Normal’ Mode. If OCR0A value’s lower, then the delay time is faster/shorter. Here's the code. OCF0A is compare flag, the bit-3 on TIFR0 register. Notice that we have to set TCCR0A register to enable CTC mode; in Normal mode we don’t have to do that.
Timer Time: Using Internal ATTiny13A Chip’s Timer “Normal” Mode (Slightly Modified)
Our timer is static, it have to wait TCNT0 to count from 0 to 255 and then start over. We could modify it so it count from x to 255 to make it count faster so we need to pre-set/pre-load TCNT0 to some value ldi a, 200 out TCNT0,a With that, we could make the delay time faster. Set the TCNT0 to lower value for longer delay
Timer Time: Using Internal ATTiny13A Chip’s Timer “Normal” Mode
Chip’s Internal Timer in ’Normal' mode will count from 0 to 255, set the overflow flag TOV0 to 0 and count again from 0 to 255, set the flag to 0 and so on. As usual, I used LED as output indicator on Port B0 We used 1024 for pre-scaler/divider value. Set the TCCR0B to 0000 0101 Note that we have to reset the overflow flag to 1 after timer count reached 255 (and set the flag to 0). Oh, by the way, the register/variable/things that count from 0 to 255 is called TCNT0. We didn’t touch it in the code this time, maybe next.
Pencerahan
Kadang datang secara tak disangka. Tak hanya pencerahan relijius seperti Sakti dari Sheila on 7 yang tiba-tiba 'terbangun' saat baca buku "Menjemput Sakaratul Maut ...." di bandara dan majalah Mati Suri di rumah sakit. Kini dia bernama Salman Al Jugjawy. Saya mengalami pencerahan secara musikal, beberapa kali. Saya termasuk telat belajar alat musik. Memiliki gitar di akhir kelas satu SMP. Awalnya belajar lagu standart Koes Plus, Iwan Fals. Dangdut populer, belajar karena ikut ekstrakurikuler band musik, manggung di tempat-tempat yang menginginkan lagu dangdut. Tembang kenangan malam-malam di radio. Saat SMU saya "Naik tingkat". Boomerang, Jamrud, Padi, Dewa19, Sheila On 7, Slank dan musik-musik populer di radio jadi sasaran. Lagi,di akhir SMU mengenal underground music. Pernah sampai diusir yang punya "studio" karena "gak niat", "ngrusak drum", "bikin sakit kuping", "liriknya gak bisa didengarkan", "bahasa apa itu?". Cuma lagu Derek yang easy listening, yang kedua adalah Bendera Kuning (kayak gitu easy listening? Yup, dibanding yang lain, ;) ) Sound gitar suka yang berdistorsi full, masuk akal memang. Efek gitar lebih suka semacam Metal Zone. Semakin djent djent djent semakin keren. Sangat anti dengan efek Overdrive . Tone harus se-treble mungkin. Dan sering frustrasi karena tidak dapat distorsi seperti di fantasi. Paling sulit meniru Eros, ada distorsi tapi nada individual tetap terdengar. Dan pencerahan itu datang.
And Finally the Breathing LED is Here, :)
Jonathan Ive style, Old Macbook Pro sleep indicator LED. Using interrupt, fast PWM on ATTiny13A.
Flip the Bit
Maybe it's just me, but I recently realized that we have a handy feature on ATTiny13A for flip the value of the bit. so instead of sbic PINB,0 cbi PINB,0 sbi PINB,0 we could just use sbi PINB,0 Saving some clocks, :)
Blinking LED using Interrupt on ATTiny13A
Here's the template .include "../tn13Adef.INC" .def a=r16 .org $0000 ; startup vector rjmp onReset .org $0006 ; compare match vector rjmp Tim0CompA onReset: sbi DDRB,0 ; port B0 as output ldi a, 0b10000011 ; pwm mode 3 out TCCR0A, a ldi a, 0b00000101 ; divider /1024 out TCCR0B,a ldi a, 0b0000100 ; enable compare interrupt out TIMSK0,a sei main: rjmp main Tim0CompA: in a, OCR0A inc a out OCR0A,a reti
Oscillating LED Blink Delay on ATTiny13A
Based on my ADC with PWM output program. The expected result is the old school MacbookPro unibody sleep indicator LED; Sir Jonathan Ive style, :) The code below resulted on slow to fast to slow to fast... blinking LED
Gendhing dan Perkusi
P Rosyid menulis tentang langgam beberapa waktu lalu. Dan saya juga ingin menulis. Memang lain, ini tentang gendhing jawa. Betapa dulu ketika masih aktif nge-band sering kesulitan menirukan lagu-lagu jawa tertentu. Bukan lagu-lagu semacam Gambang Semarang atau langgam atau Bossanova Jawa; itu relatif mudah. Lagu-lagu yang memiliki gaya klasik. Lingsir Wengi, Kusumaning Ati,... Dalam beberapa hal, musik jawa memang lain dibanding dengan musik “standar” saat ini. Di musik selain jawa. Alat-alat musik ritmis/perkusi digunakan untuk menjaga irama, menghitung ketukan, menandai birama. Entah itu drum, bongo, ketipung, tambourine atau gendang. Mereka memiliki beat tertentu.
Timer on ATTiny13A using Interrupt
It started with this
.include "../tn13Adef.inc"
.org 0000
rjmp reset
.org 0003
rjmp timer
reset:
sbi ddrb,0
ldi r16,0b00000101
out tccr0b,r16
ldi r16,0b00000010
out timsk0,r16
sei
loop:
ldi r16,(1<
ATTiny13A Arduino
ATTiny is ... well, tiny. Not very suitable to programed it on arduino. Nevertheless, I decided to do it. Create ‘hardware’ folder in Arduino sketch folder, unzip the file. Download the Smeezekitty core, http://sourceforge.net/projects/ard-core13/files/latest/download
Android Studio on My OS X Yosemite
Well, a picture is worth thousand words. So, here the millions words for you, :)
My FreeBSD Installation LeftOver
Didn't really remember the chronology. It use Parallel Desktop. It use VirtualBox too.
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.
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.
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
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
Akhirnya ...
Ujian pertama KBK Elektronika dan Instrumentasi Fisika Sangat langka memang, dan dapat hadiah uang dari P Samsul, :)
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
Full Rest, Tepar ...
Tidur jam 5 sore sampai jam 5 pagi.
Setelah melewati tiga ujian skripsi, satu ujian pra-skripsi dan mencari jarum dalam jerami versi sensor digital 40-bit untuk mikrokontroler.
12 jam tidur tanpa mimpi.
nDesa
(berangkat ngampus ingat lagu ini, sering diputar di TVRI semasa SD)
Hei aku anak desa
yang selalu gembira
tak kenal putus asa
slalu cerah ceria
Di desa ku tertawa
Di desa ku gembira
Di desa ku berkarya
untuk cita-citaku
Hidup damai ayah bunda bersamaku
Pastikan burung terbang dilangitku
Bumpy Lemans
Lorenzo, Rossi, Dovi, and crazy battle for 4th position.
Reset clock fuse bit on AVR
My ATTiny13A LED’s still blinking, but I can’t program it anymore.
How To Remove The Solder Tin Residue On Double Layered PCB
Happened to change the header pin of my arduino pro mini from male to female. Removing the female header is ridiculously tricky and there’s tin residue. Tin sucker (don’t know the proper name) couldn’t remove faster than the time to tin get hard, so theres tin in the hole, here and there... Here my pro mini after female header's removed
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.
Tengkulak
Pagi ini. Bangun Tidur. Lapar. Ups, harus masak sendiri, Alfa Beta dan istri sedang liburan. Matikan rice cooker/warmer, buang sisa nasi yang hampir kering karena lupa sebelum tidur gak kucabut stop kontaknya. Cuci wadah beras, tambahkan beras, beres. Eit, jangan lupa pasang saklar di posisi cook, nah itu dia, led berwarna orange. Sambil nunggu nasi matang, bikin lauk dulu. Kulkas kosong, ehm Sudah lama tak bersepeda pancal. Turun ke pasar kaget di daerah pabrik bawah sana sekitar tiga kilo.
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
Satu Langkah (Sheila On 7)
Satu langkah (lyrics) Telah kulakuan semua Semua tuk mendekatimu Telah kucoba segala Cara tuk cari atensimu Ingin setiap kata terucap Kau ucapkan kepadaku Kemana kau ingin berjalan S’lalu berjalan disisiku
My Lovely Asti
Hari ini dia sangat pengertian, menggemboskan ban belakang kiri di garasi, pagi hari, saat akan mengantar Alfa Beta dan ibuknya ke Kediri. Memang sempat ngedumel “duh, ngapain sih rodamu pake kempes segala”. Tapi bersyukur juga. Bayangkan jika dia memutuskan ntuk membocorkan roda di jalur antara Malang-Kediri, jalur yang terkenal macet saat libur. Jadilah paksa dia keluar garasi karena memang sempit, Alfa sempat heboh minta naik, dikira sudah mau berangkat. Saat tahu kalo si Asti pincang dia malah kegirangan “ loh, mobil merah-nya gembos ayah, …” trus lari masuk rumah tuk laporan ibuknya yang sedang mandikan Beta. Sementara pake ban serep dulu deh, buka bagasi, keluarkan ban serep dan “Ouch…”, kena salah satu kawat yang mencuat dar salah satu sudutnya, yeah, namanya juga ban cadangan, :) Masalah baru, ban serepnya juga empes, walah….
Disassembler
vAVRdisasm is an 8-bit Atmel AVR firmware disassembler. According to its site, this single-pass disassembler can read Atmel Generic, Intel HEX8, and Motorola S-Record formatted files containing valid AVR program binaries. I compile it without problem on my Macbook Air running OS X Yosemite. Simply by typing make and there it is, the binary is created. Copied it to my /usr/local/bin (or whatever you want, copy it to Desktop, or even use it as is in the download folder, in its source directory )
Sheila On 7: Selamat Datang (lyrics)
Selamat Datang (Sheila On 7) Ini lagumu yang kutuliskan untuk temani dimanapun kau. Tetap semangat jadi dewasa seperti yang kamu impikan.
ATTiny13A in Assembler
Here the assembler version I use file coba.s .include "tn13Adef.inc" .def temp = R16 //Pin assignments .equ LED = PB0 ;pin 5 of ATtiny13 .cseg .org 0x00 rjmp setup setup: //CONFIGURE I/O PINS ldi temp, (1 << LED) out PORTB, temp out DDRB,temp loop: rjmp loop Nugrohos-MacBook-Air:ATTiny13A nugroho$ ls coba.s Nugrohos-MacBook-Air:ATTiny13A nugroho$ avr-as -mmcu=attiny13A -o coba.out coba.s coba.s: Assembler messages: coba.s:1: Error: can't open tn13Adef.inc for reading: No such file or directory coba.s:2: Error: unknown pseudo-op: `.def' coba.s:3: Error: junk at end of line, first unrecognized character is `/' coba.s:4: Error: expected comma after "LED" coba.s:5: Error: unknown pseudo-op: `.cseg' coba.s:9: Error: junk at end of line, first unrecognized character is `/' coba.s:10: Error: constant value required coba.s:10: Error: register number above 15 required coba.s:11: Error: constant value required coba.s:11: Error: constant value required coba.s:12: Error: constant value required coba.s:12: Error: constant value required Oops, it needs tn13Adef.inc. Fortunately I have that on avrasm2 (it for windows for sure, but the include directory have a bunch of def files we need), copy that to the coba.s folder.
Getting Started with AtTiny13A on My Macbook Air with Yosemite
After several success attempt with arduino mini and nano (both using ATMega328), I’m curious about programming some chip in assembler. Yeah, I know we could use arduino board to do it. But I prefer to do it the “right way”, as pure assembler novice, :) So I grab the 1$ ATTiny13A and 2$ USBASP knockoff. Almost forgot the second as I think I already have one used on my Arduino Pro Mini (no, it’s USB-to-TTL, PL2303HX, only have vcc-gnd-tx-rx pins, completely different device). Turn out that my ‘other’ have some use in my system (my usbasp couldnt provide 5v power, atleast at my system, so I use usb-to-ttl instead) USBASP already detected on My Macbook Air, so no driver needed, :)
Canggung (Sheila On 7)
Canggung Melupakan tak akan mudah Walau kau telah yakin merelakan Lihat nanti lihat sendiri saat waktu yang ditentukan datang Saat bertemu lagi yang tlah hilang Tahukah betapa canggungnya tingkahku Kau beri ku lagi senyuman mautmu Kau masih sama cantik seperti dulu Seperti dulu Menyapamu di keramaian Bersikap semua terkendalikan Atur nafas atur irama dan memberimu sedikit senyuman Seandainya bisa aku katakan Tahukah betapa canggungnya tingkahku Kau beri ku lagi senyuman mautmu Kau masih sama cantik seperti dulu Seperti dulu Melanjutkan langkah yang terhenti olehmu Jiwaku tertinggal tapi tak kuhiraukan Tahukah betapa canggungnya tingkahku Kau beriku lagi senyuman mautmu Kau masih sama cantik seperti dulu seperti dulu Aku tak mau tahu perasaanmu Karna tak merubah kagumku padamu Akan kuakhiri saja lagu ini Lagu ini
Rembulan Sepasi
Rembulan antara purnama dan separo akhir. Alfa tetap menyebut sebagai bulan purnama kalo pagi-pagi kuantar ke rumah budhe, gandeng tangan kiriku, belum mandi, sambil ditambah "bulan purnama-nya dimakan jerapah", yeah, kebanyakan lihat Gazoon. Beta, sudah mandi, ikut-ikutan mas-nya, tapi belum cukup fasih bicara tuk melafalkan bulan purnama, jadinya dia baru bisa bilang " hua.. mama.." sambil lepas gandengan tangan kanan ayahnya dan segera minta gendong, tujuannya agar bisa dadah bulan sambil maksa narik tangan ayahnya tuk ikut dadah juga " dadah, hua...". Dia ingat kebiasaan mas-nya yang selalu menyapa dengan dadah kalo lihat bulan sabit sore hari di barat atau pagi hari di timur, setelah bangun tidur, sambil nunggu pus berwarna calico entah punya siapa yang selalu menyapa Beta tiap jam lima pagi dan berlalu setelah beta nongol dari pintu garasi. Eh iya, si calico punya anak tiga, dan salah satunya ikut kebiasaan induknya manggil-manggil Beta tiap jam lima pagi. Bahkan sering kulihat satu anak si calico ini, yang juga berwarna calico, tidur di keset depan rumah. Sampai-sampai Alfa, kalo ketemu si calico kecil, mulai bilang "loh ada pus kecil punya adik Kinan". Kalo kutanya "lha yang besar punya siapa", dia langsung mengklaim "punya mas Yayan", :)
Evolusi Musik Sheila On 7
Ada apa dengan musik Sheila On 7? Ingat lagu Dan di album pertama? Lagu yang sederhana dengan akord/kunci standar. Tapi banyak yang kesulitan meniru sound yang khas di lagu itu. Beberapa tahun berikutnya, setelah beberapa kali melihat performance live mereka, baru sadar bahwa Anton tidak memukul hihat di separuh pertama lagu, dia memukul floor Tom. Itu yang membuat suara khas intro Dan, juga membuat seakan-akan tempo setengah lagu lebih lambat dari paruh berikutnya yang tiba-tiba sekan jadi lebih cepat (padahal tetap sama) dan jadi lebih segar (Anton mulai menggunakan HiHat).
Adding Analog Sensor on My Arduino Nano LCD Project
I add the code from previous project so it could read analog sensor from pin A0 and display it on second row LCD. I use a potentiometer to emulate the sensor. So as result, this ATMEGA328 based device could: - read digital sensor from pin 7, display it on second rowLCD - if pin 7 is high, LED connected to pin 10 will turned on, otherwise it'll turned off - communicate via bluetooth using dedicated serial port (RX= 8 , TX = 9) - write any string sent from bluetooth to first row LCD - read string length sent from bluetooth, display it on second row LCD. - embedded LED connected to pin 13 is on if there's bluetooth serial communication
Solusi Mudah untuk Sepeda Motor Bermesin Berisik
Suara motor berisik memang mengganggu, entah itu karena mesin yang sudah lewat waktunya untuk ganti oli, bagian-bagian fairing, spatbor, sadel yang baut atau mur-nya sudah longgar sehingga bunyi gemeletuk saat di jalan tak rata maupun suara rantai yang entah kapan terakhir kali di kasih minyak dan s
Jerez
The battle for second position at start is a bit like deja vu back to two week ago at Argentina, but apparently Rossi is losing front tyre grip and Marquez's pushing himself harder despite of his little finger injury.
So, Lorenzo, Marquez, Rossi.
Modding Marshall MS-2 to Get More Gain, Attenuator and Aux-In
All I have to do is open the mini (micro?) amp obviously. There's four screw to open. The board is secured by three knobs and jack at the front so we have to screw it out as well. After the board is exposed ( :) ), locate the resistors labeled R1, and R4, replace with wire or just create jumper on it. (There's mod for more gain on Marshall and others forum [more jumper and replace the value of some resistor and caps to get higher treble and remove some noisy high freq] but I don't need gain that much [or that tone] for my bluesy sound, maybe later. For now, I'm pleased with the original Marshall MS-2 tone :) ) The Marshall characteristic that I didn't like (but I used it anyway) is we have to crank the gain up to have an overdriven sound. But that means we have a high volume out from amp. If we want to practice with full gain in the middle of the night at the normal bedroom (not sound-proof-ed), we could add a 5k potentiometer before speaker (of course we have to cut speaker positive wire) and we could practice in full gain but lower volume.