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

Click For Summary

Discussion Overview

The discussion revolves around whether to learn assembly language or C for programming the Atmega328 microcontroller. Participants explore the necessity of understanding the architecture for effective programming and share their experiences with embedded C.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested, Homework-related

Main Points Raised

  • One participant questions whether to start with assembly language or C, considering the importance of understanding the microcontroller's architecture.
  • Another participant suggests that it is possible to start directly with C, emphasizing the importance of examining compiler output to understand the underlying processes.
  • Some participants argue that knowing the hardware architecture is generally not crucial, but understanding the memory map and register functions is necessary for effective programming.
  • It is noted that using C can enhance the portability and maintainability of code, with a specific mention of using appropriate data types for efficiency.
  • A participant raises the need for C callable functions for specific hardware components and mentions scenarios where assembly might be necessary, such as for multi-tasking operating systems.
  • One participant expresses a preference for learning C directly, sharing their background knowledge of memory maps and registers, while also finding assembly language enjoyable but challenging to remember.
  • Another participant shares their experience using the Atmega328 with Arduino, highlighting the practical aspects of learning C through project work and simulation software.

Areas of Agreement / Disagreement

Participants present multiple views on whether to start with assembly or C, with no consensus reached on the necessity of understanding architecture for programming. Some emphasize the importance of practical experience and project-based learning.

Contextual Notes

Participants mention various resources and methods for learning, including the importance of understanding specific functions and libraries for programming timers and counters, but do not provide definitive sources.

Who May Find This Useful

Individuals interested in embedded systems programming, particularly those working with Atmega328 microcontrollers or similar platforms, may find this discussion relevant.

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
 

Similar threads

  • · Replies 102 ·
4
Replies
102
Views
4K
  • · Replies 25 ·
Replies
25
Views
1K
Replies
16
Views
4K
  • · Replies 122 ·
5
Replies
122
Views
18K
  • · Replies 16 ·
Replies
16
Views
5K
Replies
86
Views
3K
  • · Replies 397 ·
14
Replies
397
Views
21K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 14 ·
Replies
14
Views
5K
  • · Replies 133 ·
5
Replies
133
Views
12K