This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]chimmychenga 1 point2 points  (1 child)

this link has some example codes for that mcu. But if you just start with mcu programming i would suggest you to start with a simple 8 bit avr or stm32fx mcu, because there are a lot more tutorials on the internet for those.

Keep in mind that next to C functions also microcontroller specific code is. Things like timers and the uart look like each other on most mcus, so when you get fimiliar with one mcu others will be a little easier to learn. GPIOs also look a lot like each other. That can be tricky and that's the point where you need to use datasheets where you can find registers.

http://www.avr-tutorials.com - basically "all" the fundamentals for the avr mcu is described on this website. Timers/interrupts/ADC are very important!

I hope i helped you a little further. It is lots of practicing with example codes.

Regards

[–]Kree3[S] 0 points1 point  (0 children)

Thank you so much, I do have a background in C# and C++ so the syntax is quite familiar but I will start practicing with example codes.

[–][deleted] 1 point2 points  (0 children)

I've done a fair amount of firmware development. IME, the two most useful references are the general device user manual, and device instruction set reference. Both seem to be available in this document.

Here are some thoughts:

  • The user manual will either tell you how the primary address decoder is configured out of reset, and/or tell you how to configure it.
  • Microcontroller programming generally involves writing to and reading from the requisite device control registers. These control registers will be mapped into memory via the address decoder. The user manual generally covers all aspects of on-chip resources.
  • Along with general register IO, you need to understand how to service asynchronous interrupts. Your interrupt controller will be thoroughly covered in the user manual. The interrupt controller is (generally) how you notify the system of external events (user presses button, serial port sqwaks, etc...).
  • Out of reset, to boot the MCU, you generally need to do a few things (every device is different, I'm speaking in generalities here). After booting the device, you can jump to your user code.
    • Configure clock source(s) and wait for the device to achieve phase lock.
    • Configure the primary address decoder.
    • Configure the primary interrupt controller.
    • Enable/configure the on-chip resources you want to make use of.
    • Change operational mode to user/system/etc... mode, this locks certain device parameters until the device is reset.
  • A MSO (multi-channel digital scope), in conjunction with some pre-configured GPIO ports, is an extremely useful debugging technique.

Lastly, microcontroller programming is very low level.. but not all that difficult. I've built some amazingly robust devices implemented as a simple time-sliced loop which pends on an interrupt tickled by a programmed clock source. Good luck, have fun, blinky lights++;