Overview
The ATMega644P/V is equivalent to other AVR microcontrollers, ATMega16, ATMega32 and ATMega1284 etc, in footprint. However its Flash memory is 64kB with larger size in SRAM and data EEPROM. The ATMega644P could operates up to 20MHz with the supply voltage between 4.5 and 5.5VDC.
Using its larger memory size and high speed clock we can use this chip for graphical LCD controlling, TFT LCD controlling, Graphical User Interface (GUI) and embedded networking etc.
Input Output Port Interfacing and Programming
Using the Microchip Studio IDE from the device manufacture we can program a simple I/O port from scratch using a few lines of C code.
![]() |
| ATMega644P 40-Pin DIP Pin Diagram |
There are some paid compiler for this chip family, IAR Embedded Workbench, CodeVision AVR and MikroC Pro for AVR etc. These Compiler has a lot of built-in libraries and technical support.
PortB Blink
Since this MCU able to operates at 20MHz I tested this capability to blink the LED connects to PortB for every 1000 seconds.
- /*
- * 1-blink_port_b_20M.c
- *
- * Created: 1/25/2026 2:45:25 PM
- * Author : Admin
- */
- #include <avr/io.h>
- #include <util/delay.h>
- #define F_CPU 20000000UL
- const uint32_t d_time=1000;
- int main(void)
- {
- /* Replace with your application code */
- DDRB=0xFF;
- while (1)
- {
- PORTB=0xFF;
- _delay_ms(d_time);
- PORTB=0x00;
- _delay_ms(d_time);
- }
- }
Proteus VSM also has a model for this chip.
![]() |
| Schematic |
I tested this demo program on my breadboard since my prototype board doesn't have a 20MHz clock.
PortB LED Shift
I use my AVR Prototype Board to test the ATMega644P. This example chases and shifts the LED at PortB.
- /*
- * 1-shift_port_b_16M.c
- *
- * Created: 1/24/2026 9:49:48 PM
- * Author : Admin
- */
- #include <avr/io.h>
- #include <util/delay.h>
- #define F_CPU 16000000UL
- int main(void)
- {
- /* Replace with your application code */
- DDRB=0xFF;
- while (1)
- {
- for (uint8_t i=0;i<8;i++)
- {
- PORTB=(1<<i);
- _delay_ms(100);
- }
- _delay_ms(2000);
- PORTB=0;
- for (uint8_t i=0;i<8;i++)
- {
- PORTB|=(1<<i);
- _delay_ms(100);
- }
- _delay_ms(2000);
- PORTB=0;
- for (int8_t i=7;i>=0;i--)
- {
- PORTB=(1<<i);
- _delay_ms(100);
- }
- _delay_ms(2000);
- PORTB=0;
- for (int8_t i=7;i>=0;i--)
- {
- PORTB|=(1<<i);
- _delay_ms(100);
- }
- _delay_ms(2000);
- PORTB=0;
- for (uint8_t i=0;i<0xFF;i++)
- {
- PORTB=rand();
- _delay_ms(100);
- }
- _delay_ms(2000);
- PORTB=0;
- }
- }
The schematic remains the same to about example. But it excepts that the on board clock oscillator is 16MHz.
I have been using PCBWay for many years now. PCBWay fabricate PCBs at low cost, fast processing time for only 24 hours, and fast delivery time using any carrier options. This double side 10cmx10cm can be fabricate at only 5USD for 5 to 10pcs by PCBWay. It's a standard PCB with silk screen and solder mask.
![]() |
| 10 PCBs for only 5USD |
For different size of PCB we can instantly quote on PCBWay website using a zip PCB Gerber file without account.
![]() |
| PCBWay Instant Quote |
I tested this demo example on my AVR Prototype Board.
Switches and LED
There are three push buttons and 8 LED on the prototype board. So I will the its input and output pins.
- /*
- * 2-InputOutput_2_16M.c
- *
- * Created: 1/25/2026 9:55:36 AM
- * Author : Admin
- */
- #include <avr/io.h>
- int main(void)
- {
- /* Replace with your application code */
- DDRB=0xFF;
- DDRB&=~(1<<2);
- DDRD=0x00;
- PINB=(1<<2);
- PIND=(1<<2)|(1<<3);
- uint8_t tmp1=0,tmp2;
- while (1)
- {
- tmp1=(PINB&0x04);
- tmp1<<=3;
- tmp2=(PIND&0x04)|(PIND&0x08);
- tmp2<<=4;
- PORTB=tmp1|tmp2;
- }
- }
We can simulate this program in Proteus VSM without testing on Prototype Board.
Six Digits 7-Segment Display
There is six-digit common cathode multiplexing display. The ATMega644P drives each digits for 5ms repeatedly to make it readable.
- /*
- * 3-6_digits_swap.c
- *
- * Created: 1/25/2026 12:16:51 PM
- * Author : Admin
- */
- /************************************************************************/
- /* This Sample Program is designed for the ATMega16 Development Board */
- /************************************************************************/
- #include <avr/io.h>
- #include <util/delay.h>
- #define F_CPU 16000000UL
- const uint8_t cc_7[16]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,
- 0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};
- const uint16_t d_time=5;
- int main(void)
- {
- /* Replace with your application code */
- DDRB=0xFF;
- DDRC=0xFF;
- while (1)
- {
- PORTC=0;
- PORTB=cc_7[0];
- PORTC=0x20;
- _delay_ms(d_time);
- PORTC=0;
- PORTB=cc_7[1];
- PORTC=0x40;
- _delay_ms(d_time);
- PORTC=0;
- PORTB=cc_7[2];
- PORTC=0x80;
- _delay_ms(d_time);
- PORTC=0;
- PORTB=cc_7[3];
- PORTC=0x04;
- _delay_ms(d_time);
- PORTC=0;
- PORTB=cc_7[4];
- PORTC=0x08;
- _delay_ms(d_time);
- PORTC=0;
- PORTB=cc_7[5];
- PORTC=0x10;
- _delay_ms(d_time);
- }
- }
I tested it both in software simulator and hardware.
I swapped each displays in Proteus VSM to fit the on-board display.
You can check the detail of this prototype board in pcbway that I shared many years now.














No comments:
Post a Comment