Atmega 2560 Collatz Calculator

As a project for CSC 230: Introduction to Computer Architecture, I was tasked with designing a program that would run the Collatz Sequence. Furthermore, the program was to be controllable by a user via the keypad shield. This was so that the user could update the value to run the sequence on as well as to control the speed that the sequence processed at.

The program was assigned to be written in AVR Assembler language. This allowed me to understand how to program registers and utilize the stack and its push/pop operations. I also learned how to incorporate timer driven interrupts and how to set the appropriate registers, as well as perform analog to digital conversion (ADC) on the values received from the 5 keypad buttons.

Writing in Assembly is drastically different from any other programming language but it helped better understand what goes on behind the scenes in low-level programming.

This same program was written in C as the final project for this course. It's crazy how 1500 lines of Assembly code turned into about 200 lines of C code.


n - input value to begin the sequence at
SPD - current speed of sequence
cnt - number of terms in sequence thus far
v - current value of sequence

Top row is editable by the cursor (n and SPD)
Bottom row (cnt and v) are calculated by the sequence