{"id":274,"date":"2013-05-22T15:58:59","date_gmt":"2013-05-22T13:58:59","guid":{"rendered":"http:\/\/www.aquilin.nl\/?page_id=274"},"modified":"2018-12-04T20:28:52","modified_gmt":"2018-12-04T20:28:52","slug":"stm32f05x-other-projects","status":"publish","type":"page","link":"https:\/\/ese.han.nl\/~harends\/wpsite\/?page_id=274","title":{"rendered":"More"},"content":{"rendered":"<p>This page contains even more topics that are not explicitly part of the lessons.<\/p>\n<h1>Bit manipulation<\/h1>\n<p>Manipulating individual bits in registers is important in microcontroller programming. A detailed discussion of bitwise operators is presented here:<\/p>\n<p><a href=\"https:\/\/ese.han.nl\/~harends\/wpsite\/?page_id=589\">Bit manipulation<\/a><\/p>\n<h1><strong style=\"color: #000000;\">HD44780 based LCD<\/strong><\/h1>\n<p>In lesson 6 you have seen how to interface an I2C-based LCD to the STM32F05x. If you rather use a 14\/10-bit HD44780 interface, then check out the following example project. It implements a HD44780 driver on top of the STM standard peripheral driver library.<\/p>\n<p><a title=\"STM32F05x HD44780 example code\" href=\"https:\/\/docs.google.com\/file\/d\/0B-H5UhFxO23xeDVzMDJTSFBZWUE\/edit?usp=sharing\">STM32F05x\u00a0HD44780 example code<\/a><\/p>\n<h1><strong>LIS302D\u00a0accelerometer<\/strong><\/h1>\n<p>An other I2C example is provided for the LIS302D accelerometer. The example shows how to setup the hardware and howto read and write from the internal registers. It uses the standard peripheral driver library, but as a reference, in comments the CMSIS implementation is shown.<\/p>\n<p><a title=\"STM32F05x LIS302D example code\" href=\"https:\/\/docs.google.com\/file\/d\/0B-H5UhFxO23xV1dMTnN6ZHBjdEE\/edit?usp=sharing\">STM32F05x\u00a0LIS302D example code<\/a><\/p>\n<h1><strong>Assembly programming<\/strong><\/h1>\n<p>Some projects require parts of it to be written in assembly. This example shows how this can be done in Keil uVision in two ways. The first is how to write external functions in a *.s file and shows how parameters are passed.\u00a0The second one shows how to use inline assembly and how C-variables can be referenced.<br \/>\nBoth example programs run on the STM32F0Discovery board. For debugging the simulator is enabled by default.<\/p>\n<p><a title=\"STM32F05x ASM example code\" href=\"https:\/\/docs.google.com\/file\/d\/0B-H5UhFxO23xLWUwaldCOXBMbkE\/edit?usp=sharing\">STM32F05x\u00a0ASM example code<\/a><\/p>\n<h1><strong>74HC595 drivers<\/strong><\/h1>\n<p>One way to expand the I\/O&#8217;s of a project is using a serial in and parallel out shift register like the <a title=\"74HC595\" href=\"http:\/\/www.nxp.com\/documents\/data_sheet\/74HC_HCT595.pdf\">74HC595<\/a>. This example project shows two targets that implement a driver for the 74HC595. The first target implements the driver with toggling GPIO pins, often called &#8216;bit-banging&#8217;. The second target implements the driver using the SPI interface. The beauty of this example is that the main routine remains the same, because both drivers implement the same Application Programming Interface (API)!<\/p>\n<p><a title=\"STM32F05x 74HC595 example code\" href=\"https:\/\/docs.google.com\/file\/d\/0B-H5UhFxO23xb1NKR2N3d251ek0\/edit?usp=sharing\">STM32F05x 74HC595 example code<\/a><\/p>\n<h1><strong>Custom Hardware<\/strong><\/h1>\n<p>This lesson gives an example where the STM32F051R8T6 microcontroller is used on a custom PCB and how it can be programmed using the SWD interface which is available on the STM32F0-Discovery board.<\/p>\n<p><a href=\"https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2014\/02\/STM32F05x-custom-hardware-schematic1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-395 size-medium\" src=\"https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2014\/02\/STM32F05x-custom-hardware-schematic1-300x199.png\" alt=\"STM32F05x custom hardware schematic\" width=\"300\" height=\"199\" srcset=\"https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2014\/02\/STM32F05x-custom-hardware-schematic1-300x199.png 300w, https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2014\/02\/STM32F05x-custom-hardware-schematic1-768x509.png 768w, https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2014\/02\/STM32F05x-custom-hardware-schematic1-1024x678.png 1024w, https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2014\/02\/STM32F05x-custom-hardware-schematic1.png 1250w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a title=\"STM32F05x custom hardware\" href=\"https:\/\/docs.google.com\/document\/d\/1kRaThUuBrVf2oP0d61cXS8_rk0NKMu9n_7b8tza0WMs\/pub\" target=\"_blank\" rel=\"noopener\">STM32F05x custom hardware lesson<\/a><br \/>\n<a title=\"STM32F05x custom hardware example code\" href=\"https:\/\/drive.google.com\/file\/d\/0B-H5UhFxO23xWFFYbzBDcF85bU0\/edit?usp=sharing\">STM32F05x custom hardware example code<\/a><\/p>\n<h1><strong>Using the High Speed Internal (HSI) 8 MHz oscillator<\/strong><\/h1>\n<p>The STM32F05x microcontroller has three clock sources:<br \/>\n&#8211; High Speed Internal (HSI) 8 MHz RC oscillator clock<br \/>\n&#8211; High Speed External (HSE) oscillator clock<br \/>\n&#8211; Phase-Locked Loop (PLL) clock<\/p>\n<p>The STM32F0-Discovery board firmware examples all use an 8 MHz HSE clock as an input for the PLL to get the microcontroller to clock at 48 MHz. This setup is done in the file &#8216;system_stm32f0xx.c&#8217;.<br \/>\nThis example has an updated version of this file so it sets up the HSI as an input for the PLL and still clock the microcontroller at 48 MHz. Care must be taken however, because the exact internal RC oscillator frequency varies depending on variations in temperature and operating voltage.\u00a0This new file has been generated with the <a title=\"Clock Configuration Tool for STM32F0xx Microcontrollers\" href=\"http:\/\/www.st.com\/web\/en\/catalog\/tools\/PF257924#\" target=\"_blank\" rel=\"noopener\">Clock Configuration Tool for STM32F0xx Microcontrollers<\/a>.<\/p>\n<p><a title=\"STM32F05x HSI example code\" href=\"https:\/\/drive.google.com\/file\/d\/0B-H5UhFxO23xRnRHSXU0bW96Sk0\/edit?usp=sharing\">STM32F05x HSI example code<\/a><\/p>\n<h1><strong>Starting a new project<\/strong><\/h1>\n<p>All lessons provide an example project for \u03bcVision. This lesson describes in a nutshell how to start a new project in \u03bcVision.<\/p>\n<p><a title=\"STM32F05x custom hardware lesson\" href=\"https:\/\/docs.google.com\/document\/d\/1ml5OPzUEWzEZ1Q7OI1wpEwttf3x7aoi-0b4q-Gnksnc\/pub\" target=\"_blank\" rel=\"noopener\">STM32F05x\u00a0new project lesson<\/a><\/p>\n<h1><strong>Tips for debugging<\/strong><\/h1>\n<p>When you try to watch the value of a variable during a debug session, you might see the following message instead of it&#8217;s actual value: <strong>&lt;out of scope&gt;<\/strong><br \/>\nThis most likely means that this variable has been optimized out by the compiler and is in fact not in scope of the debugger (see this <a title=\"Compiler User Guide\" href=\"http:\/\/www.keil.com\/support\/man\/docs\/armcc\/armcc_pge1396882387898.htm\" target=\"_blank\" rel=\"noopener\">link<\/a> for detailed information about optimization levels and debugging in Keil uVision).<\/p>\n<p>There are several things you can do:<br \/>\n&#8211; lower the optimization level.<br \/>\n&#8211; declare the variable you would like to watch static.<\/p>\n<p>In the following example, the variable has been declared static. When you watch this variable in a &#8216;Watch window&#8217;, it&#8217;s value is updated live during runtime.<br \/>\n<em>BTW. Did you know you can also see live the values of all registers in the System Viewer Windows?<\/em><br \/>\nHappy debugging \ud83d\ude42<br \/>\n<a href=\"https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2015\/06\/debugging.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-431 size-medium\" src=\"https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2015\/06\/debugging-300x164.png\" alt=\"debugging\" width=\"300\" height=\"164\" srcset=\"https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2015\/06\/debugging-300x164.png 300w, https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2015\/06\/debugging-768x419.png 768w, https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2015\/06\/debugging-1024x559.png 1024w, https:\/\/ese.han.nl\/~harends\/wpsite\/wp-content\/uploads\/2015\/06\/debugging.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><em>One more debugging tip.<\/em> Did you know the STM32F0 microcontroller features <strong>four breakpoints<\/strong> and <strong>two watchpoints<\/strong>? When you set more in uVision unexpected behavior (like unable to step through the source code) might be experienced. So be sure to not use more break- and watchpoints then supported by the microcontroller.<\/p>\n<hr \/>\n<div class=\"g-plusone\" data-size=\"medium\" data-href=\"http:\/\/www.aquilin.nl\/?page_id=4\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This page contains even more topics that are not explicitly part of the lessons. Bit manipulation Manipulating individual bits in registers is important in microcontroller programming. A detailed discussion of bitwise operators is presented here: Bit manipulation HD44780 based LCD &hellip; <a href=\"https:\/\/ese.han.nl\/~harends\/wpsite\/?page_id=274\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":199,"parent":554,"menu_order":9,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=\/wp\/v2\/pages\/274"}],"collection":[{"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=274"}],"version-history":[{"count":5,"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=\/wp\/v2\/pages\/274\/revisions"}],"predecessor-version":[{"id":644,"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=\/wp\/v2\/pages\/274\/revisions\/644"}],"up":[{"embeddable":true,"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=\/wp\/v2\/pages\/554"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=\/wp\/v2\/media\/199"}],"wp:attachment":[{"href":"https:\/\/ese.han.nl\/~harends\/wpsite\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}