3
ezbie
7y

!rant

I wanted to know a few suggestions of cheap/easy microcontrollers for you to learn a bit of assembly.

Nothing fancy though, I just want to experiment with these things.

Comments
  • 2
    I learnt assembly with AVRs. They are fairly simple, so you don't need a lot of initialisation code to get going. It very possible to fully understand these controllers and you can actually count instruction clock cycles. The assembly itself has a few minor pecularities like similar mnemonics expecting bit masks vs. bit offsets or instructions not applicable on certain registers. But overall, it is very nice to use, because the large number of registers is actually enough for most tasks.

    MSP430 assembly is also pretty nice but I can't say much about it because I don't know it that well. The controllers themselves are nice and simple and the low-power modes seem well integrated and are easy to use. They aren't very cheap though.

    The most useful in the embedded world is probably ARM assembly, but you're dealing with vastly more complex controllers there and won't be able to get going with 5 lines of assembly like with AVRs.
  • 1
    I started learning with AVRs. They are pretty simple and you can find everything you need on the data sheets. I tried PIC but it annoyed me that you have to keep switching between a "Code" and "Data" space 😅

    I think there are probably a lot better resources out there for AVRs too. And programming with AVR Studio is a delightful experience 😁
  • 1
    @7400 @mrstebo what about avr's on Linux? Because it seems like I'll have to switch to windows if I want to use their IDE.
  • 1
    @ezbie yeah... Worth it though 😬
  • 1
    @ezbie I did of all development on AVRs with a simple USBasp, so without any debugging functionality. In my opinion, well-integrated debugging is the core aspect of an IDE and everything else can be done well within an appropriately-featured editor. Today's editors offer nice code completion and I don't trust IDEs' build systems anyway.

    I ditched AVR Studio a long time ago and never really missed it. Development with vim and makefiles worked fine for me.

    I remember using the integrated simulator in AVR Studio a few times while beginning to use the controllers. That helped me grasping some concepts, but of course isn't necessary. I don't know if there are any alternatives for Linux here.
  • 1
    @7400 got it.

    Btw, do u have any suggestion of a controller to start with.

    Because, I mean, I intend to learn how computer's work internally with this assembly thing. It doesn't need to be a pain, like a very complex controller, but I don't think I want to learn anything architecturally too different from PC's (like, Harvard Archichtecture).

    Any suggestion for someone who knows nothing about assembly?
  • 1
    @ezbie I actually know next to nothing about x86/x64 assembly. x86/x64 assembly is useful either if you're doing reverse engineering or very low level work on PCs, both of which is rare. I'd guess it gets complicated pretty soon with these, too.

    In the embedded world you'll be dealing with Harvard machines 99% of the time. But for newer architectures, peripherals are memory-mapped anyways and often code execution from RAM is possible, so this distinction doesn't matter that much from a programming point of view.

    I'd suggest to get a controller as simple as possible. That way, you can easily get in the mindset of assembly programming and get a feeling what is going on inside the processor. Complications can be added later.

    Maybe you want to have a look at the early microprocessors like 6502, 68000, Z80, or 8051, because there you'll have a very clear, well-understandable system architecture. I've never programmed any of those, so I unfortunately can't give any advise on these.
  • 1
    For those you'll find good simulators where you can relly look inside and trace what your code is doing.

    If you want real hardware, I'd still suggest AVRs or MSP430s.
  • 1
    @7400 Okay, one last question, how do you interact with the controller during runtime? I took a look at the USBasp and the compatible chips and I was wondering how you input/output data, or does it only accepts hard coded programs?
  • 0
    Silly question, I know, but that's just what I thought.
  • 1
    No, this is a good question and you're right in your guess. The USBasp can only flash programs into the chips memory but while running the microcontroller is on its own.

    Debugging can be achieved by methods as simple as toggling an LED or using a serial interface to print debug information. I think the TinyISP (another USB ISP programmer) has a feature where you can print over the ISP pins via SPI, so you don't need another interface.

    If you want real debugging, you can get something like a AVR Dragon. On larger controllers I wouldn't want to be without debugging, but on AVRs I actually never tried it. Most of the hardware-specific faults in larger controllers, for which a debugger is extremely useful, don't exist in the AVR's simple architecture.

    But of course, single-stepping through your assembly and watching the register contents change is a very nice learning experience. I had done this in the integrated simulator in AVR Studio.
  • 1
    I would recommend that you get a simple ISP and maybe a debugger later because setting up a debugger and using it gets a lot easier when you already know about the target's architecture.

    With an ISP and a proper editor you can get really fast development cycles (compile and flash in maybe a second for small programs), so changing something and reflashing again isn't tiring, so LED debugging is viable.
  • 1
    @7400 Ok, thanks for your given thoughts.
    Good look with your programming :)
  • 1
    @ezbie You too!
Add Comment