{"id":224,"date":"2018-09-10T09:31:41","date_gmt":"2018-09-10T13:31:41","guid":{"rendered":"http:\/\/drsmith.blog.yorku.ca\/?p=224"},"modified":"2018-09-10T09:31:41","modified_gmt":"2018-09-10T13:31:41","slug":"choosing-a-platform-for-teaching-microcontroller-programming","status":"publish","type":"post","link":"https:\/\/www.yorku.ca\/professor\/drsmith\/2018\/09\/10\/choosing-a-platform-for-teaching-microcontroller-programming\/","title":{"rendered":"Choosing a platform for teaching microcontroller programming"},"content":{"rendered":"<p>While planning a book on programming microcontrollers I've been trying to settle on a small group of microcontrollers that could be used for examples. Every couple of years I do this to myself.\u00a0 Below are a few examples, including the ubiquitous Arduino UNO with an 8-bit chip, as well as the FRDM-KL25Z and Adafruit Metro M0 Express boards with ARM Cortex chips.\u00a0 It's also possible to create simple designs using a breadboard and stand-alone chips, as you can see in the breadboard illustration with three chips: <a href=\"http:\/\/: http:\/\/drsmith.blog.yorku.ca\/2018\/09\/a-simple-program\u2026are-and-contrast\/\">two PIC16s and one ATMEGA328<\/a>.\u00a0 In the book I'd like to contrast C code on three or four platforms, perhaps two 8-bit PIC\/AVR and two 32-bit ARM Cortex examples per concept.\u00a0 It'll be a challenge to keep things compact, but the exercise might prove beneficial for understanding (and catching errors!).<\/p>\n<div id=\"attachment_226\" style=\"width: 1124px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-226\" class=\"size-full wp-image-226\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/fritzing_micros_v2.png\" alt=\"Examples of microcontroller boards and stand-alone chips that could be used for a self-learning, debug-centric C programming course.\" width=\"1114\" height=\"762\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/fritzing_micros_v2.png 1114w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/fritzing_micros_v2-300x205.png 300w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/fritzing_micros_v2-1024x700.png 1024w\" sizes=\"auto, (max-width: 1114px) 100vw, 1114px\" \/><p id=\"caption-attachment-226\" class=\"wp-caption-text\">Examples of microcontroller boards and stand-alone chips that could be used for a self-learning, debug-centric C programming course (from upper-left, clockwise: FRDM KL25Z, Arduino UNO, Adafruit Metro M0 Express, the breadboarded ATMEGA 328 (not complete), PIC16F1619 with debug header and PIC16F84A with debug header.<\/p><\/div>\n<p>I've created a table to compare and contrast a short-list of candidates.\u00a0 The emphasis is on trying to find an \"out-of-the-box\" product that would permit a student or self-learner with minimal experience to get up-and-running quickly.\u00a0 Hardware should be complete and boards should be available from reputable vendors, including resellers and should be relatively inexpensive.\u00a0 Serial monitors are not considered appropriate, so a debugging port (e.g. ICSP, JTAG or SWD) is required.\u00a0 If construction is required, then breadboarding is favoured over soldering.\u00a0 For this reason, the 8-bit PIC and AVR solutions on breadboard are preferred over off-the-shelf boards that require soldering of debug headers.\u00a0 Fritzing parts files are a bonus because it'll make it easier to create illustrations (board view and schematics).<\/p>\n<div id=\"attachment_227\" style=\"width: 1422px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-227\" class=\"size-full wp-image-227\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/micros_table_sept2018.png\" alt=\"Table comparing microcontroller solutions for a programming book. Green is favourable, Yellow is moderately favourable and Orange is rejected.\" width=\"1412\" height=\"721\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/micros_table_sept2018.png 1412w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/micros_table_sept2018-300x153.png 300w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/micros_table_sept2018-1024x523.png 1024w\" sizes=\"auto, (max-width: 1412px) 100vw, 1412px\" \/><p id=\"caption-attachment-227\" class=\"wp-caption-text\">Table comparing microcontroller solutions for a programming book. Green is favourable, Yellow is moderately favourable and Orange is rejected.<\/p><\/div>\n<p>I've got over this process a few times in the past few months.\u00a0 I'm thinking that my choice is boiling down to this:<\/p>\n<ol>\n<li>ATMEGA 328 (breadboard and Arduino).\u00a0 It's just so popular, so by including it the audience is broader and deeper.\u00a0 By showing the <a href=\"https:\/\/bit.ly\/2oRZHKx\">breadboard<\/a> version it helps get at the idea that the microcontroller is the chip, not the board.\u00a0 <a href=\"http:\/\/www.microchip.com\/mplab\/mplab-x-ide\">MPLAB X<\/a> support, now available, is better than AVR Studio or command-line gcc, making it better for novices who want\/need to go beyond the Arduino IDE.\u00a0 Plus, a lot of current material online relies on the old tools.\u00a0 Time for an update.<\/li>\n<li>PIC16. <a href=\"https:\/\/bit.ly\/2x03KJk\">This<\/a>, and the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Freescale_68HC11\">68HC11<\/a>, are the 1990s version of the Arduino.\u00a0 The PIC16s, in spite of being much maligned, are widely used, <a href=\"https:\/\/archive.org\/details\/EasyPicing\">well documented<\/a>, simple and the <a href=\"http:\/\/www.microchip.com\/mplab\/mplab-x-ide\">IDE<\/a> is free, multiplatform and holistic (simulator and debugger support).\u00a0 As of 2018, the IDE (<a href=\"http:\/\/www.microchip.com\/mplab\/mplab-x-ide\">MPLAB X<\/a>) now supports ATMEGA and SAMD, too, but the support for PIC is better for the time being.\u00a0 <a href=\"https:\/\/bit.ly\/2x03KJk\">PIC16F84A<\/a>, while old, is a really simple chip and has basic PICKit3 debugger support, making a good target for examining disassembled code, as well as assembler from scratch.\u00a0 I'm trying it out for a course at INSA Strasbourg in the Fall of 2018. The <a href=\"http:\/\/blog.flyingpic24.com\/2015\/04\/16\/8-bit-is-easier-this-is-not-rocket-science-new-book-on-lulu\/\">PIC16F1619<\/a> is a new generation alternative with a new core and new peripherals on a cheap <a href=\"https:\/\/bit.ly\/2NxKXhG\">Curiosity board with built-in debugger<\/a>, making <a href=\"http:\/\/blog.flyingpic24.com\/2015\/04\/16\/8-bit-is-easier-this-is-not-rocket-science-new-book-on-lulu\/\">breadboard<\/a> or premade boards good options, depending on the learner.<\/li>\n<li>Cortex M0+.\u00a0 I initially rejected this back around 2008 in my former job because the teaching material and hardware were not ready for pedagogical primetime, much to the chagrin of my \"oh shiny!\" obsessed colleagues. Ten years later, my tune has changed.\u00a0 Cheap boards, with built-in debuggers and really good IDE+compilers from NXP and Microchip are responsible for this.\u00a0 The NXP <a href=\"https:\/\/bit.ly\/2Mg1ulO\">FRDM KL25Z<\/a> (or alternatively the <a href=\"https:\/\/bit.ly\/2Qj9Tbj\">FRDM KL22F<\/a> with soldered SWD port), and the <a href=\"https:\/\/bit.ly\/2En5PQu\">Adafruit Metro M0 Express<\/a> or <a href=\"https:\/\/bit.ly\/2MiHxep\">Microchip SAMD21 Xplained<\/a> provide professional grade debugging hardware in ultra-cheap boards. Wonderful.<\/li>\n<\/ol>\n<p>I'd like to use Arduino-brand Cortex boards because of the recognition that the Arduino brand brings, but it's clear that Massimo and company have<a href=\"https:\/\/groups.google.com\/a\/arduino.cc\/forum\/m\/#!topic\/developers\/HEKecd0qhS4\"> had a lot of trouble selling and supporting their ARM products<\/a>.\u00a0 Maybe they're victims of the success of their ATMEGA-based products or maybe there is some complex issues with development or supply chain that I can't fathom, but their history is not good when it comes to ARM.\u00a0 So alternatives from other companies like Microchip, Adafruit and NXP are likely to be better.<\/p>\n<p>While there are five or six variants of hardware to examine, only two IDEs (<a href=\"http:\/\/www.microchip.com\/mplab\/mplab-x-ide\">MPLAB X<\/a> and <a href=\"http:\/\/mcuxpresso.nxp.com\/\">MCUXpresso<\/a>) need to be used for creating examples.\u00a0 MPLAB X supports more chips (PIC16, ATMEGA and SAMD) but it is limited to the <a href=\"http:\/\/ww1.microchip.com\/downloads\/en\/DeviceDoc\/MPLAB_XC8_C_Compiler_User_Guide_for_PIC.pdf\">C90<\/a> and <a href=\"http:\/\/ww1.microchip.com\/downloads\/en\/DeviceDoc\/50001686J.pdf\">C99<\/a> C programming standards, whereas MCUXpresso can go up to C14, as shown below.\u00a0 If necessary, the SAMD and Kinetis parts could be tested using the open source project <a href=\"https:\/\/gnu-mcu-eclipse.github.io\/\">GNU MCU Eclipse<\/a>, which might support a more current version of the C standard (C++, too).<\/p>\n<div id=\"attachment_232\" style=\"width: 1649px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-232\" class=\"wp-image-232 size-full\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/compiler_comparison_c99_c11_c1z.png\" alt=\"Comparison of C standards in MPLAB X and MCUXpresso (2018).\" width=\"1639\" height=\"616\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/compiler_comparison_c99_c11_c1z.png 1639w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/compiler_comparison_c99_c11_c1z-300x113.png 300w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/compiler_comparison_c99_c11_c1z-1024x385.png 1024w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/compiler_comparison_c99_c11_c1z-1536x577.png 1536w\" sizes=\"auto, (max-width: 1639px) 100vw, 1639px\" \/><p id=\"caption-attachment-232\" class=\"wp-caption-text\">Comparison of C standards in MPLAB X and MCUXpresso (2018). MPLAB X is up to C99 and MCUXpresso is up to C14, maybe C18.<\/p><\/div>\n<p>The more words I write here the more I realize that the breadth of example hardware might be too much. (This post was supposed to take an hour but I've spent the better part of a day on it... an indication of things to come?)\u00a0 But it should be easy to cut back if I see that, right?<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div class=\"mceTemp\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>While planning a book on programming microcontrollers I've been trying to settle on a small group of microcontrollers that could be used for examples. Every couple of years I do this to myself.\u00a0 Below are a few examples, including the ubiquitous Arduino UNO with an 8-bit chip, as well as the FRDM-KL25Z and Adafruit Metro [&hellip;]<\/p>\n","protected":false},"author":762,"featured_media":226,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","footnotes":""},"categories":[45,46,48,54],"tags":[67,10,72,73,77,80,5,92,93,94,95,110,111,139,170,239],"class_list":["post-224","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-2","category-c-programming","category-embedded","category-pedagogy","tag-adafruit","tag-arduino","tag-arm-cortex","tag-arm-cortex-m","tag-atmega","tag-avr","tag-c","tag-c17","tag-c11","tag-c14","tag-c18","tag-cortex","tag-cortex-m0","tag-gcc","tag-kinetis","tag-stm32"],"taxonomy_info":{"category":[{"value":45,"label":"c"},{"value":46,"label":"c programming"},{"value":48,"label":"embedded"},{"value":54,"label":"pedagogy"}],"post_tag":[{"value":67,"label":"adafruit"},{"value":10,"label":"arduino"},{"value":72,"label":"arm cortex"},{"value":73,"label":"arm cortex m"},{"value":77,"label":"atmega"},{"value":80,"label":"AVR"},{"value":5,"label":"c++"},{"value":92,"label":"c++17"},{"value":93,"label":"c11"},{"value":94,"label":"c14"},{"value":95,"label":"c18"},{"value":110,"label":"cortex"},{"value":111,"label":"cortex m0"},{"value":139,"label":"gcc"},{"value":170,"label":"kinetis"},{"value":239,"label":"stm32"}]},"featured_image_src_large":["https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2018\/09\/fritzing_micros_v2-1024x700.png",1024,700,true],"author_info":{"display_name":"drsmith","author_link":"https:\/\/www.yorku.ca\/professor\/drsmith\/author\/drsmith\/"},"comment_info":"","category_info":[{"term_id":45,"name":"c","slug":"c-2","term_group":0,"term_taxonomy_id":45,"taxonomy":"category","description":"","parent":0,"count":51,"filter":"raw","cat_ID":45,"category_count":51,"category_description":"","cat_name":"c","category_nicename":"c-2","category_parent":0},{"term_id":46,"name":"c programming","slug":"c-programming","term_group":0,"term_taxonomy_id":46,"taxonomy":"category","description":"","parent":0,"count":50,"filter":"raw","cat_ID":46,"category_count":50,"category_description":"","cat_name":"c programming","category_nicename":"c-programming","category_parent":0},{"term_id":48,"name":"embedded","slug":"embedded","term_group":0,"term_taxonomy_id":48,"taxonomy":"category","description":"","parent":0,"count":38,"filter":"raw","cat_ID":48,"category_count":38,"category_description":"","cat_name":"embedded","category_nicename":"embedded","category_parent":0},{"term_id":54,"name":"pedagogy","slug":"pedagogy","term_group":0,"term_taxonomy_id":54,"taxonomy":"category","description":"","parent":0,"count":28,"filter":"raw","cat_ID":54,"category_count":28,"category_description":"","cat_name":"pedagogy","category_nicename":"pedagogy","category_parent":0}],"tag_info":[{"term_id":67,"name":"adafruit","slug":"adafruit","term_group":0,"term_taxonomy_id":67,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":10,"name":"arduino","slug":"arduino","term_group":0,"term_taxonomy_id":10,"taxonomy":"post_tag","description":"","parent":0,"count":17,"filter":"raw"},{"term_id":72,"name":"arm cortex","slug":"arm-cortex","term_group":0,"term_taxonomy_id":72,"taxonomy":"post_tag","description":"","parent":0,"count":3,"filter":"raw"},{"term_id":73,"name":"arm cortex m","slug":"arm-cortex-m","term_group":0,"term_taxonomy_id":73,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":77,"name":"atmega","slug":"atmega","term_group":0,"term_taxonomy_id":77,"taxonomy":"post_tag","description":"","parent":0,"count":3,"filter":"raw"},{"term_id":80,"name":"AVR","slug":"avr","term_group":0,"term_taxonomy_id":80,"taxonomy":"post_tag","description":"","parent":0,"count":4,"filter":"raw"},{"term_id":5,"name":"c++","slug":"c","term_group":0,"term_taxonomy_id":4,"taxonomy":"post_tag","description":"","parent":0,"count":5,"filter":"raw"},{"term_id":92,"name":"c++17","slug":"c17","term_group":0,"term_taxonomy_id":92,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":93,"name":"c11","slug":"c11","term_group":0,"term_taxonomy_id":93,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":94,"name":"c14","slug":"c14","term_group":0,"term_taxonomy_id":94,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":95,"name":"c18","slug":"c18","term_group":0,"term_taxonomy_id":95,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":110,"name":"cortex","slug":"cortex","term_group":0,"term_taxonomy_id":110,"taxonomy":"post_tag","description":"","parent":0,"count":2,"filter":"raw"},{"term_id":111,"name":"cortex m0","slug":"cortex-m0","term_group":0,"term_taxonomy_id":111,"taxonomy":"post_tag","description":"","parent":0,"count":3,"filter":"raw"},{"term_id":139,"name":"gcc","slug":"gcc","term_group":0,"term_taxonomy_id":139,"taxonomy":"post_tag","description":"","parent":0,"count":3,"filter":"raw"},{"term_id":170,"name":"kinetis","slug":"kinetis","term_group":0,"term_taxonomy_id":170,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":239,"name":"stm32","slug":"stm32","term_group":0,"term_taxonomy_id":239,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"}],"_links":{"self":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts\/224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/users\/762"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/comments?post=224"}],"version-history":[{"count":0,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts\/224\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/media\/226"}],"wp:attachment":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/media?parent=224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/categories?post=224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/tags?post=224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}