Modul PBM 5 (Assembly)
Modul PBM 5 (Assembly)
Modul PBM 5 (Assembly)
MODUL PERKULIAHAN
PERANCANGAN
BERBASIS
MIKROPROSESOR
Assembly
05
Zendi Iklima, M.Sc
Fakultas Teknik Teknik Elektro
ATmega328
ATmega-328 is basically an Advanced Virtual RISC (AVR) micro-controller. It
supports the data up to eight (8) bits. ATmega-328 has 32KB internal builtin memory. This
micro-controller has a lot of other characteristics.
ATmega 328 has 1KB Electrically Erasable Programmable Read Only Memory
(EEPROM). This property shows if the electric supply supplied to the micro-controller is
removed, even then it can store the data and can provide results after providing it with the
electric supply. Moreover, ATmega-328 has 2KB Static Random Access Memory (SRAM).
ATmega 328 has several different features which make it the most popular device
in today’s market. These features consist of advanced RISC architecture, good
performance, low power consumption, real timer counter having separate oscillator, 6 PWM
pins, programmable Serial USART, programming lock for software security, throughput up
to 20 MIPS etc. ATmega-328 is mostly used in Arduino.
(please have a look ATMega328 Datasheet you’ve downloaded)
• ATmega328 is an 8-bit and 28 Pins AVR Microcontroller,
manufactured by Microchip, follows RISC Architecure and has a
flash type program memory of 32KB.
• It has an EEPROM memory of 1KB and its SRAM memory is of
2KB.
• It has 8 Pin for ADC operations, which all combines to form PortA
( PA0 – PA7 ).
• It has 3 builtin Timers, two of them are 8 Bit timers while the third
one is 16-Bit Timer.
• Operates ranging from 3.3V to 5.5V but normally we use 5V as a
standard.
Flash Memory has 32KB capacity. It has an address of 15 bits. It is a Programmable Read
Only Memory (ROM). It is non volatile memory.
SRAM stands for Static Random Access Memory. It is a volatile memory i.e. data will be
removed after removing the power supply.
EEPROM stands for Electrically Erasable Programmable Read Only Memory. It has a long
term data.
ATmega328 Registers
The ATmega328P needs to know how you are using its pins. Are they inputs or
outputs? That is the purpose of the data direction registers. You write a 1 to make a pin an
output and a 0 to make it an input. In our example, PD0 to PD3 will be outputs, while PD4
to PD7 will be inputs. PD0 corresponds to DDD0 in the DDRD register. The other pins
follow the same pattern as PD0. We now have enough information to write a line of code
to establish which pins are inputs or outputs:
DDRD = 0b00001111;
ATmega328 Pinout
Code Explanations
r16 is register shown in slide
2021 Pengantar Ilmu Bahan
8 Biro Bahan Ajar E-learning dan MKCU
Zendi Iklima, M.Sc
10.
http://pbael.mercubuana.ac.id/
We already simulated these code using proteus/ISIS.
You need to check the OpCode in the Datasheet you’ve downloaded in the previous
lecture (ATMega328 Datasheet page 12 section 6. Instruction Set).
clr reg_temp
whatever).
This relative jump loops us back to our Main:
label and we check PinD again and so on.
Checking every 16 millionth's of a second
whether the button is being pushed and setting
PB0 accordingly.
Conclusion
ser register sets all of the bits of a register to 1’s
in register, i/o register copies the number from an i/o register to a working register
Submissions
Answer the following exercises that you found on the slides (exercises 1-7).
The file contains : PDF file (Source Code, Screen Shoot, etc) and MP4 (Screen Recorder)