Author Topic: Starting with MCU's  (Read 3946 times)

0 Members and 1 Guest are viewing this topic.

Offline alihashemiTopic starter

  • Newbie
  • Posts: 6
  • Country: us
Starting with MCU's
« on: August 25, 2015, 08:58:35 pm »
Hi All:

I've been working with Arduino and Energia (processing/wiring, in other words) up until now. These, however, don't seem like platforms you can code in for product that you intend on sending to production. I've worked with different ICs, I2C, SPI, parallel, etc. just as some background. I've had a tough time finding tutorials and such for full blow development for MCUs. I'm assuming I should pick a family and stick to learning programming for that one family. If I just plan on developing small, battery operated electronics/wearables, does anyone have a family of MCUs they can recommend and any idea where I can begin learning programming for that family?

Thanks in advance,
Ali
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: Starting with MCU's
« Reply #1 on: August 25, 2015, 09:30:28 pm »
The Arduino is basically an AVR board with a bootloader, you can just switch to Atmel Studio. Ditto for Code Composer Studio and the MSP430.

Offline alihashemiTopic starter

  • Newbie
  • Posts: 6
  • Country: us
Re: Starting with MCU's
« Reply #2 on: August 25, 2015, 10:51:44 pm »
The Arduino is basically an AVR board with a bootloader, you can just switch to Atmel Studio. Ditto for Code Composer Studio and the MSP430.

That's what I thought, but, this brings up something that I've been confused about for a long time. In wiring/processing, there are libraries that setup interrupts, the SPI bus, etc. do these also exist in CCS or Atmel studio or do we have to code the initialization, the pins, etc. ourselves? If so, is this different for each family of processors? If so, where can I find documentation on this? It just seems too easy when you're coding in Arduino, etc.
 

Offline Maxlor

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: ch
Re: Starting with MCU's
« Reply #3 on: August 26, 2015, 12:35:18 am »
All the info you need is in the chip datasheets with those simple 8-bit MCUs. Both Microchip and Atmel supply very complete and easy to understand (imo, I guess) documentation, go there first. I found the MSP430 docs to be slightly less accessible due to them being split up into several documents, but they're certainly complete as well.

You can use the Arduino IDE to ease into things if you like, by not using the supplied libraries but starting to work with the processor registers directly. It's probably not a good idea to mix and match library calls and direct register access, because those lib calls are doing quite a bit more than you'd think. If you want to start with a proper IDE, yeah, you'll likely have to do a good part of the setup yourself, but it's not that complex with 8-bit MCUs. Something like the SPI hardware controller will have between 2 and 5 registers with options you can set, such as baud rate, bit order and polarity, and if the defaults happen to work for you, maybe all you need to do is set the "enable" bit.

With the Arduino IDE, you also get the source code. Go have a look at the source for the digitalWrite() function for example. Reference that to the datasheet, and you should get a pretty good understanding of how the chip works. And, probably, some distaste for Arduino, as you realize how much performance they sacrifice in their effort to tolerate coding errors.
 

Offline retrolefty

  • Super Contributor
  • ***
  • Posts: 1648
  • Country: us
  • measurement changes behavior
Re: Starting with MCU's
« Reply #4 on: August 26, 2015, 12:50:28 am »
The Arduino is basically an AVR board with a bootloader, you can just switch to Atmel Studio. Ditto for Code Composer Studio and the MSP430.

That's what I thought, but, this brings up something that I've been confused about for a long time. In wiring/processing, there are libraries that setup interrupts, the SPI bus, etc. do these also exist in CCS or Atmel studio or do we have to code the initialization, the pins, etc. ourselves? If so, is this different for each family of processors? If so, where can I find documentation on this? It just seems too easy when you're coding in Arduino, etc.

 Your on your own for all the functions that the arduino
(+Wiring functions) supplies in it's libraries. Of course the source code is included so it would not be all the difficult to recreate those basic supplied functions under a different IDE.

 

Offline ralphd

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: ca
    • Nerd Ralph
Re: Starting with MCU's
« Reply #5 on: August 26, 2015, 02:24:08 am »
The Arduino is basically an AVR board with a bootloader, you can just switch to Atmel Studio. Ditto for Code Composer Studio and the MSP430.

That's what I thought, but, this brings up something that I've been confused about for a long time. In wiring/processing, there are libraries that setup interrupts, the SPI bus, etc. do these also exist in CCS or Atmel studio or do we have to code the initialization, the pins, etc. ourselves? If so, is this different for each family of processors? If so, where can I find documentation on this? It just seems too easy when you're coding in Arduino, etc.
Ditto to reading the datasheet.
For libraries, avr-libc gives you low-level stuff like _delay_ms(), sleep mode control functions, eeprom read/write, but no SPI and millis timer.
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline bufo333

  • Newbie
  • Posts: 2
  • Country: us
Re: Starting with MCU's
« Reply #6 on: August 26, 2015, 02:52:54 am »
My recommendation is to read the book "AVR Programming: Learning to Write Software for Hardware 1st Edition" The link in amazon is here. http://www.amazon.com/Make-Programming-Learning-Software-Hardware/dp/1449355781/ref=sr_1_1?ie=UTF8&qid=1440556966&sr=8-1&keywords=make+avr&pebp=1440556961045&perid=161R0AYHVAC4EMRTEZHR

He takes you through reading the datasheet, configuring pins and editing registers directly, and a large part of the book is building your own SPI, I2C, USART, and other libraries that come by default in wiring and Arduino. The biggest thing I find is that you will become really familiar with the underlying MCU, and in some cases your understanding of the ADC and other functions will become more clear. You will find yourself coding small efficient libraries in C not the bloated object oriented c++ Arduino/Wiring stuff. The book also teaches you some minimal c programming such as how to save these projects as libraries so you can reuse I2C or your own Shift Register library so you can include it in future projects.

You will also find yourself extending your own libraries in the future as you wanted additional features. For instance my 8 bit parallel LCD library I created while using the book lacked the ability to print a register or uint8_t variable directly to the LCD as a binary number. I coded up a small function so that my LCDPrint() function had the ability to take a BIN parameter which would cycle through the byte and print a 0 or 1 on the LCD for each of the bits. This was really useful for debugging programs.

Additionally there are lots of sites such as avrfreaks that have really professionally done c libraries for all of the above and in many cases 40 to 60 times faster and less resource intensive than the Arduino/Wiring versions. I am only going through the exercise of coding my own, just to familiarize myself with the MCU and to get a better idea how this technology works and become a better programmer. In a lot of cases I will compare my code to other really well done libraries and get ideas for how to do things better.


You also might be interested in this youtube video where the author of the books explains quite a bit of the book to a live audience and takes questions.  https://youtu.be/ERY7d7W-6nA
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: Starting with MCU's
« Reply #7 on: August 26, 2015, 08:07:25 pm »
I'm assuming I should pick a family and stick to learning programming for that one family. If I just plan on developing small, battery operated electronics/wearables,
So are you asking us which uC family comes with smallest chip scale package (BGA 1.5 x 1.5mm) or which uC can run from a single 0.9V discharged LR44 coin cell or perhaps this is the question for the fastest development environment of a small 100kB application really?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->