6
\$\begingroup\$

I've written code for AVRs for several years now and it seems like my needs are calling for a more powerful processor. Since Atmel Studio is the IDE I'm already using and my debugger also works with ARM MCUs, going with an Atmel device seemed like a no-brainer. The troubles began when I tried to actually start and write some code. AVRs have an endless amount of tutorials on forums such as avrfreaks.net but the Atmel ARM MCUs do not. To make things worse, Atmel offers, almost exclusively, code that is written with its ASF software framework which means that if I want to use it I have to adopt a pretty high level approach which I don't like in coding, as I am not entirely aware of what goes on under the hood.

My question is: if someone went through a similar path, what was the correct place to start and learn how to use these M3 MCUs without the ASF!

\$\endgroup\$
  • 3
    \$\begingroup\$ When using an Atmel or PIC, I never used the vendor-supplied function libraries. With an ARM, however, most people do use the libraries. I don't know about ASF, but if it is CMSIS-compliant, then the code is much more easily ported to other ARM controllers. Also, other ARM developers will recognize the coding style... I started using the STM32F series controller and have never looked back. ST provides their "Standard Peripheral Library", which is CMSIS-compliant. \$\endgroup\$ – bitsmack Nov 19 '14 at 22:40
  • \$\begingroup\$ infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0234a/… \$\endgroup\$ – m.Alin Nov 19 '14 at 23:33
  • \$\begingroup\$ You spend much more code setting up,enabling, and configuring peripherals and their clocks, but once you do they're easy to use \$\endgroup\$ – Scott Seidman Nov 20 '14 at 2:27
  • \$\begingroup\$ @bitsmack I tried to learn Atmel ARM based as my first 32bit platform and was overwhelmed. Then i stumbled onto stm32 and in your word i never looked back. Even that datasheets I find more easier to understand. I am not a fan of thier systemwork bench IDE but I do like Keil. \$\endgroup\$ – Edwin Fairchild Jun 27 '18 at 4:01
6
\$\begingroup\$

No one forces you to use a peripheral library (ASF), you may very well code directly by toggling bits pretty much like on AVRs. The ASF probably includes a file which contains all the registers' definitions so that you can code manually if you want to.

I also found that the peripheral library (for STM32, though) was not easy to use when I started, but once you understand how it works, you no longer need to care about low level idiosyncrasies of your device, so that your code is more portable and faster to develop. I must admit that I prefer to code directly with registers, but there is a reason why ARM provide a kind of standard (CMSIS) for peripheral libraries and it is for ease of use: once you know an ARM, you know most of them, because the peripheral library wraps most differences behind a layer of abstraction. You are better off taking a not-so-steep learning curve with the peripheral library provided for your chip (there are tons of examples on the Internet using peripheral libraries) than using register configuration, because you will end up with very few examples on the Internet.

Start with a small project and then try using peripherals using the library. If you really want not to use it, then you probably will be on your own, but still, you can look in the ASF to see how they implemented stuff and reinvent the wheel if you want to. Your call.

\$\endgroup\$
  • \$\begingroup\$ No one is forcing me to use ASF, that is true in the sense that no one puts a gun to my head but it does seems like the exclusive reading material I can get my hands on from Atmel. I understand the needs to simplify the coding process due to the increased complexity of the devices, however the lack of info on what goes under has its share or downs. For example, I tried to use the ADC, followed the app. note and at the end nothing happens (code compiles / no update to the variable). I don't know why and feeling helpless. \$\endgroup\$ – user34920 Nov 20 '14 at 2:14
  • \$\begingroup\$ @user34920 did you turn on the clock to the adc? Not remembering to clock the peripherals is my most common error. \$\endgroup\$ – Scott Seidman Nov 20 '14 at 2:28
  • \$\begingroup\$ @ScottSeidman - using sysclk_enable_peripheral_clock()? I don't know how to find the parameter list. Is there also need to enable the ADC through the PMC? \$\endgroup\$ – user34920 Nov 20 '14 at 10:47
  • \$\begingroup\$ Yup. I don't know your family, but the correct clock on the correct bus needs to be enabled. I don't know about enabling the adc on the pmc, but based on my limited stm32 experience, probably. \$\endgroup\$ – Scott Seidman Nov 20 '14 at 12:29
  • \$\begingroup\$ Start with a working example, and play with that. \$\endgroup\$ – Scott Seidman Nov 20 '14 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.