{"id":24312476,"url":"https://github.com/mytechnotalent/atmega328p_uart_driver","last_synced_at":"2026-05-19T14:08:49.358Z","repository":{"id":272527864,"uuid":"916899091","full_name":"mytechnotalent/ATmega328P_UART_Driver","owner":"mytechnotalent","description":"An ATmega328P UART driver written entirely in Assembler.","archived":false,"fork":false,"pushed_at":"2025-06-08T21:29:24.000Z","size":1109,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T04:06:33.339Z","etag":null,"topics":["arduino","arduino-nano","arduino-platform","arduino-programming","arduino-project","assembler","assembly","atmega328p","avr","avr-programming","avrdude","uart"],"latest_commit_sha":null,"homepage":"","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mytechnotalent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-15T00:56:20.000Z","updated_at":"2025-06-08T21:29:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"0d3a2a61-cb6d-4635-a6fc-777cf8b1298e","html_url":"https://github.com/mytechnotalent/ATmega328P_UART_Driver","commit_stats":null,"previous_names":["mytechnotalent/atmega328p_uart_driver"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mytechnotalent/ATmega328P_UART_Driver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mytechnotalent%2FATmega328P_UART_Driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mytechnotalent%2FATmega328P_UART_Driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mytechnotalent%2FATmega328P_UART_Driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mytechnotalent%2FATmega328P_UART_Driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mytechnotalent","download_url":"https://codeload.github.com/mytechnotalent/ATmega328P_UART_Driver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mytechnotalent%2FATmega328P_UART_Driver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006255,"owners_count":26084060,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","arduino-nano","arduino-platform","arduino-programming","arduino-project","assembler","assembly","atmega328p","avr","avr-programming","avrdude","uart"],"created_at":"2025-01-17T08:17:53.376Z","updated_at":"2026-05-19T14:08:49.350Z","avatar_url":"https://github.com/mytechnotalent.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/mytechnotalent/ATmega328P_UART_Driver/refs/heads/main/ATmega328P%20UART%20Driver.png\"\u003e\n\n## FREE Reverse Engineering Self-Study Course [HERE](https://github.com/mytechnotalent/Reverse-Engineering-Tutorial)\n\n\u003cbr\u003e\n\n# ATmega328P UART Driver\nAn ATmega328P UART driver written entirely in Assembler.\n\n\u003cbr\u003e\n\n# Code\n```assembler\n; ===================================================================\n; Project: ATmega328P UART Driver\n; ===================================================================\n; Author: Kevin Thomas\n; E-Mail: ket189@pitt.edu\n; Version: 1.0\n; Date: 12/29/24\n; Target Device: ATmega328P (Arduino Nano)\n; Clock Frequency: 16 MHz\n; Toolchain: AVR-AS, AVRDUDE\n; License: Apache License 2.0\n; Description: This program is a simple I/O to which when a button\n;              connected to PD2 is pressed, an external LED connected\n;              to PD4 will illuminate, otherwise it will be off and\n;              utilizes UART at 9600 baud and echos every char \n;              pressed.\n; ===================================================================\n\n; ===================================================================\n; SYMBOLIC DEFINITIONS\n; ===================================================================\n.equ     DDRD, 0x0A               ; Data Direction Register for PORTD\n.equ     PORTD, 0x0B              ; PORTD Data Register\n.equ     PIND, 0x09               ; Input Pins Address for PORTD\n.equ     PD2, 2                   ; Pin 2 of PORTD (D2 on Nano)\n.equ     PD4, 4                   ; Pin 4 of PORTD (D4 on Nano)   \n.equ     UCSR0A, 0xC0             ; USART0 Control \u0026 Status Reg A\n.equ     UCSR0B, 0xC1             ; USART0 Control \u0026 Status Reg B\n.equ     UCSR0C, 0xC2             ; USART0 Control \u0026 Status Reg C\n.equ     UBRR0L, 0xC4             ; USART0 Baud Rate Register Low\n.equ     UBRR0H, 0xC5             ; USART0 Baud Rate Register High\n.equ     UDR0, 0xC6               ; USART0 I/O Data Register\n.equ     RXEN0, 4                 ; USART0 Receiver Enable\n.equ     TXEN0, 3                 ; USART0 Transmitter Enable\n.equ     UDRE0, 5                 ; USART0 Data Register Empty\n.equ     RXC0, 7                  ; USART0 Receive Complete\n.equ     UCSZ00, 1                ; character size\n.equ     UCSZ01, 2                ; character size\n\n; ===================================================================\n; PROGRAM ENTRY POINT\n; ===================================================================\n.global  program                  ; global label; make avail external\n.section .text                    ; start of the .text (code) section\n\n; ===================================================================\n; PROGRAM LOOP\n; ===================================================================\n; Description: Main program loop which executes all subroutines and \n;              then repeads indefinately.\n; -------------------------------------------------------------------\n; Instructions: AVR Instruction Set Manual\n;               6.87 RCALL – Relative Call to Subroutine\n;               6.90 RJMP – Relative Jump\n; ===================================================================\nprogram:\n  RCALL  Config_Pins              ; config pins\n  RCALL  UART_Init                ; UART init\nprogram_loop:\n  RCALL  Check_Button             ; check button state; control LED\n  RCALL  Poll_UART                ; non-blocking check; incoming char\n  RJMP   program_loop             ; infinite loop\n\n; ===================================================================\n; SUBROUTINE: Config_Pins\n; ===================================================================\n; Description: Main configuration of pins on the ATmega128P Arduino \n;              Nano.\n; -------------------------------------------------------------------\n; Instructions: AVR Instruction Set Manual\n;               6.33 CBI – Clear Bit in I/O Register\n;               6.95 SBI – Set Bit in I/O Register\n;               6.88 RET – Return from Subroutine\n; ===================================================================\nconfig_pins:\n  CBI    DDRD, PD2                ; set PD2 as input (button pin)\n  SBI    PORTD, PD2               ; enable pull-up resistor on PD2\n  SBI    DDRD, PD4                ; set PD4 as output (LED pin)\n  RET                             ; return from subroutine\n\n; ===================================================================\n; SUBROUTINE: UART_Init\n; ===================================================================\n; Description: Initializes UART0 for serial communication at 9600 baud, \n;              8 data bits, no parity, 1 stop bit.\n; -------------------------------------------------------------------\n; Instructions: AVR Instruction Set Manual\n;               6.63 LDI – Load Immediate\n;               6.117 STS – Store Direct to Data Space\n;               6.83 ORI – Logical OR with Immediate\n;               6.88 RET – Return from Subroutine\n; ===================================================================\nUART_Init:\n  LDI    R16, 103                ; set 9600 baud rate low byte\n  STS    UBRR0L, R16             ; store in UBRR0L\n  LDI    R16, 0                  ; set 9600 baud rate high byte\n  STS    UBRR0H, R16             ; store in UBRR0H\n  LDI    R16, (1 \u003c\u003c RXEN0)       ; enable RX (Receiver Enable)\n  ORI    R16, (1 \u003c\u003c TXEN0)       ; enable TX (Transmitter Enable)\n  STS    UCSR0B, R16             ; store in UCSR0B\n  LDI    R16, (1 \u003c\u003c UCSZ00)      ; set UCSZ00 (Bit 2) for 8 data bits\n  ORI    R16, (1 \u003c\u003c UCSZ01)      ; set UCSZ01 (Bit 1) for 8 data bits\n  STS    UCSR0C, R16             ; store in UCSR0C\n  RET                            ; return from subroutine\n\n; ===================================================================\n; SUBROUTINE: Check_Button\n; ===================================================================\n; Description: Checks if PD2 is pressed and if so, drive LED high,\n;              otherwise drive LED low.\n; -------------------------------------------------------------------\n; Instructions: AVR Instruction Set Manual\n;               6.97 SBIS – Skip if Bit in I/O Register is Set\n;               6.96 SBIC – Skip if Bit in I/O Register is Cleared\n;               6.88 RET – Return from Subroutine\n; ===================================================================\nCheck_Button:\n  SBIS   PIND, PD2                ; skip next inst if PD2 is high\n  RCALL  LED_On                   ; if PD2 is low; BTN pressed\n  SBIS   PIND, PD2                ; skip next inst if PD2 is low\n  RCALL  LED_Off                  ; if PD2 is high; BTN not pressed\n  RET                             ; return from subroutine\n\n; ===================================================================\n; SUBROUTINE: LED_On\n; ===================================================================\n; Description: Sets PB5 high to turn on the LED.\n; -------------------------------------------------------------------\n; Instructions: AVR Instruction Set Manual\n;               6.95 SBI – Set Bit in I/O Register\n;               6.88 RET – Return from Subroutine\n; ===================================================================\nled_on:\n  SBI    PORTD, PD4               ; set PD4 high\n  RET                             ; return from subroutine\n\n; ===================================================================\n; SUBROUTINE: LED_Off\n; ===================================================================\n; Description: Clears PB5 to turn off the LED.\n; -------------------------------------------------------------------\n; Instructions: AVR Instruction Set Manual\n;               6.33 CBI – Clear Bit in I/O Register\n;               6.88 RET – Return from Subroutine\n; ===================================================================\nLED_Off:\n  CBI    PORTD, PD4               ; set PD4 low\n  RET                             ; return from subroutine\n\n; ===================================================================\n; SUBROUTINE: Poll_UART\n; ===================================================================\n; Description: Non-blocking UART polling. If a byte arrives, it is \n;              echoed back via UART.\n; -------------------------------------------------------------------\n; Instructions: AVR Instruction Set Manual\n;               6.114 LDS – Load Direct from Data Space\n;               6.101 SBRS – Skip if Bit in Register is Set             \n;               6.88 RET – Return from Subroutine\n;               6.115 STS – Store Direct to Data Space\n; ===================================================================\nPoll_UART:\n  LDS    R16, UCSR0A             ; load UCSR0A\n  SBRS   R16, RXC0               ; skip next if RXC0 is set; has data\n  RET                            ; return from subroutine\n  LDS    R16, UDR0               ; read received byte from UDR0\n.Poll_TX_Wait:\n  LDS    R17, UCSR0A             ; load UCSR0A\n  SBRS   R17, UDRE0              ; skip next if UDRE0 is set; buf rdy\n  RJMP   .Poll_TX_Wait           ; wait until buffer is ready\n  STS    UDR0, R16               ; write byte to UDR0 (transmit)\n  RET                            ; return from subroutine\n```\n\n\u003cbr\u003e\n\n# License\n[Apache License 2.0](https://github.com/mytechnotalent/ATmega328P_UART_Driver/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmytechnotalent%2Fatmega328p_uart_driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmytechnotalent%2Fatmega328p_uart_driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmytechnotalent%2Fatmega328p_uart_driver/lists"}