Thursday, May 21, 2015

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$ 

.