Tuesday, August 22, 2017

microcontroller Programming


The AVR 8-Bit RISC Microcontroller from Atmel is a very common Microcontroller It's a single integrated circuit with EEPROM, Ram, Analog to Digital converter, a lot of digital input and output lines, timers, UART for RS 232 communication and many other things.

The best is however that a complete programming environment is available under Linux: You can program this Microcontroller in C using GCC. In this article I will explain how to install and use GCC. I will as well explain how to load the software into the Microcontroller. All you need for this are an AT90S4433 Microcontroller, a 4Mhz crystal, some cable and a few other very cheap parts.

Sunday, April 9, 2017

ATmega8

A monitoring and protection circuit for 1-cell and 2-cell Li-ion applications that require high security and authentication, accurate monitoring, low cost, and high utilization of the cell energy. The microcontroller includes 8KB self-programming flash program memory, 512-Bytes SRAM, 256-Bytes EEPROM, 1 or 2 cells in series, over-current, high-current and short-circuit protection, 12-bit voltage A/D converter, 18-bit coulomb counter current A/D converter, and debugWire interface for on-chip debug. The device features autonomous battery protection during charging and discharging, and supports very accurate accumulated current measurements using an 18-bit ADC with a resolution of 0.84??V. It also supports up to 4 MIPS throughput at 4MHz. 1.8 - 9V operation. Parameter Name Value Program Memory Type Flash Program Memory (KB) 8 CPU Speed (MIPS) 16 RAM Bytes 1 Data EEPROM (bytes) 512 Digital Communication Peripherals 1-UART, 1-SPI, 1-I2C Capture/Compare/PWM Peripherals 11 CCP3 Comparators 1 Temperature Range (C) -40 to 85 Operating Voltage Range (V) 2.7 to 5.5 Pin Count 32 Cap Touch Channels 12

Saturday, February 25, 2017

Serial Program


                                org         0h
                nop
                call          masukserial
                mov       dptr,#MyCharacter
loop:                      clr           A
                Movc     A,@A+dptr
                cjne       A,#0,Next
                sjmp      loop1
Next:                     call          out
                inc          dptr
                sjmp      loop
loop1:                   call          input
                cjne       A,#'1',next1
                mov       P0,#30h
                mov       p1,#31h
               
next1:                   cjne       A,#'2',next2
                mov       P0,#31h
                mov       p1,#30h
next2:                   cjne       A,#'3',nextx
                mov       P0,#39h
                mov       p1,#34h
nextx:                   sjmp      loop1
;
masukserial:
                mov       scon,#52h ; Konfigurasi komunikasi serial mode 1
                mov       tmod,#20h ; Baud rate 2400 BPS
                                MOV     TH0,#81H
                                MOV     TL0,#4AH
                                MOV     TH1,#0f3h
                                MOV     TL1,#32H
                setb       tr1
                                SETB      PT1
                                SETB      ET1
                                SETB      EA
                                ret
;
input:
detecti:                jnb         ri,detecti ; Deteksi bit RI apakah data sudah diterima  atau belum
                clr           ri
                mov       a,sbuf
                ret
;
out:
detecto:               jnb         ti,detecto;
                clr           ti ;
                mov       sbuf,a ;
                ret
;
MyCharacter:
                DB ' Tekan Tombol 1, 2 atau 3',13,10,0
                End
      

Friday, February 24, 2017

The Program of Running Led

org         0h
                jmp        mulai
mulai:

cek1:     jb            p1.0,cek2                             ; cek penekanan tombol 2
             call          kanan                                   ; call label kanan
cek2:     jb            p1.1,cek3                             ; cek penekanan tombol 1
              call          kiri
cek3:     jb            p1.2,cek1
             call          mati                                       ; call label kiri
             sjmp      mulai                                     ; kembali ke label mulai
;--------------------------------------------
kanan:               mov       a,#01111111b                    ; isi data accu dengan     01111111b
kanan1:             mov       p0,a                                   ; isi data accu di p0
                         call          delay                                ; call delay
                         jb            p1.1,terus                        ;cek penekanan tombol pada kanan1
                         sjmp      kembali                             ; kembali ke label kembali
terus:                jb            p1.2,terus1                         ; cek penekanan tombol pada terus1
                        sjmp      kembali                                ; kembali ke kembali

terus1: 
                        rr             a                                   ; putar data accu ke kanan
                      cjne       a,#11111110b,kanan1    ;bandingkan data 11111110b dengan data di accu lalu ke label                     kanan1
                       sjmp      kanan1                            ; kembali ke label kanan1
kembali:               ret
                                                                                ; kembali ke program awal
kiri:         mov       a,#11111110b                    ; isi data accu dengan 11111110b
kiri1:      mov       p0,a                                       ; isi data accu di p0
                call          delay
                                                                ; call delay
                jb            p1.2,next                             ; cek penekanan tombol pada next
                sjmp      back                                       ; kembali ke label back
next:     jb            p1.0,next1                          ; cek penekanan tombol paada next1
                sjmp      back                                       ; kembali ke label back
next1:   rl             a                                              ; putar data accu ke kiri
                cjne    a,#011111111b,kiri1            ; bandingkan data 01111111b dengan data di accu lalu ke kiri1
                sjmp      kiri1                                        ; kembali ke label kiri1
back:     ret                                                          ; kembali ke program awal

mati:      mov       a,#11111111b
mati1:   mov       p0,a
                call          delay
                jb            p1.0,lanjut
                sjmp      kanan
lanjut:   jb            p1.1,lanjut1
                sjmp      kiri
               

lanjut1: jmp        mulai
                ret
;===========================================
;subroutine delay time
delay:    mov       r2,#180                                 ; isi data register 2 dangan 180h
delay1: mov       r3,#250                                 ; isi data register 3 dengan 250h
delay2: djnz       r3,delay2                             ; kurangi register 3 jika belum 0 jangan lompat ke delay2
                djnz       r2,delay1                             ; kurangi register 2 jika belum 0 jangan lompat ke delay1
                ret                                                          ; kembali ke program awal
                end                                                        ; program berakhir