Should I Learn Assembly Language or C for New Atmega328 Board?

AI Thread Summary
When starting with an ATmega328 board, it's generally recommended to jump straight into programming with C rather than learning assembly language first. Understanding the microcontroller's memory map and register functions for input and output hardware is essential, but in-depth knowledge of the architecture is not strictly necessary. However, aligning data types with the microcontroller's bus width, such as using 8-bit unsigned chars, can enhance code efficiency.For those new to embedded C, it's important to access C callable functions for specific hardware features like timers and serial ports. Resources for learning about programming these functions can include books and online materials. Engaging in practical projects is suggested as a way to deepen understanding of C programming, especially under real-world constraints, which can foster creativity and problem-solving skills. Simulation software like Proteus can also be beneficial for testing without incurring costs for physical components.
reddvoid
Messages
118
Reaction score
1
I got new atmega328 board
should i learn assembly language first or jump directly to programming with C ?
is knowing inside architecture necessary for programming micro controller using embedded c ?
 
Technology news on Phys.org
No you can go strait into C. You should examine the compiler output though to make sure you have a feel for what it's doing.

You have to know the memory map and register functions for the input and output hardware. But no, you don't have to know the architecture. It'd be a good idea though.
 
Using C for your embedded software will improve portability and maintainability of your code. Knowing the details of the hardware architecture is generally not important.

However, the one (and by far most relevant) architectural aspect to keep in mind is choosing data types for variables that match the micro controller's bus width. Using 8-bit unsigned chars will result in the most efficient code size and execution speed for the atmega328.
 
Last edited by a moderator:
Did you also get C callable functions (library and header files) for accessing the cpu specific stuff like the timers, serial ports, ... ? If so, you'll need to understand how to use those functions, if not, you'll have to understand how to program those components.

If you were to write your own multi-tasking operating system, you might need to write some assembly code to handle other cpu specific stuff like interrupt handling and task (context) switching.
 
thanks for the response guys,
I like to go straight to C i learned memory map and different registers special function registers and about timers and counters from from its data sheet but i feel coding in assembly language is fun but need to remember lot of stuff .
and i know basic embedded c
but where can i get in detail about functions like DDRx programing timers and counters and all . . . programming in C? Any book ,online resources are also welcome.
 
reddvoid, I am using also ATMega 328 attached to the board of Arduino, it has been one month I use it...it is also my first time to deal with C programming which is very interesting because after I make the program, I can test it whether it works or not in the real process.

Anw, I am using Proteus simulation software which mean I can reduce the cost of buying stuffs, :D

My suggestion, the best way to dig deeper of C by doing a project.
I am tasked to make project in the factory I am doing my internship, then It gives me pressure, responsibility, and time limited to exert my creativity and spirit!

Anyway I start learning C by just reading from other people projects and doing test and error, it seems fun :D
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top