{"id":6284,"date":"2024-07-30T10:06:21","date_gmt":"2024-07-30T08:06:21","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=6284"},"modified":"2024-07-30T21:49:36","modified_gmt":"2024-07-30T19:49:36","slug":"analog-audio-output-on-an-stm32h7","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/","title":{"rendered":"Analog Audio Output on an STM32H7"},"content":{"rendered":"<p>In <a href=\"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/25\/the-power-of-stm32h7-microcontrollers\/\">my last post<\/a>, I have introduced you to the powerful <strong>STM32H743VIT6<\/strong> microcontroller.<\/p>\n<p>Now it is time to <strong>test some audio output<\/strong>.<\/p>\n<p>I don&#8217;t have any special implementation for the output of analog audio for the STM32H7, but I decided to try to use my generic implementation that is part of by my <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\">AudioTools library<\/a> which is based on the Arduino analogWrite() in combination with a timer.<\/p>\n<p>I adapted the <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\/blob\/main\/examples\/examples-stream\/streams-generator-analog\/streams-generator-analog.ino\">standard example<\/a> to use stereo and defined the analog pins PA4 and PA5 which are connected to the internal DAC:<\/p>\n<pre><code>#include \"AudioTools.h\"\n\nAudioInfo info(44100, 2, 16);\nSineWaveGenerator&lt;int16_t&gt; sineWave(32000);                \nGeneratedSoundStream&lt;int16_t&gt; sound(sineWave);             \nAnalogAudioStream out; \nStreamCopy copier(out, sound);                             \nint pins[] = {PA4, PA5}\n\n\/\/ Arduino Setup\nvoid setup(void) {  \n  \/\/ Open Serial \n  Serial.begin(115200);\n  AudioLogger::instance().begin(Serial, AudioLogger::Warning);\n\n  \/\/ start the analog output\n  auto config = out.defaultConfig(TX_MODE);\n  config.setPins(pins);\n  config.copyFrom(info); \n  out.begin(config);\n\n  \/\/ Setup sine wave\n  sineWave.begin(info, N_B4);\n  Serial.println(\"started...\");\n}\n\n\/\/ Arduino loop - copy sound to out \nvoid loop() {\n  copier.copy();\n}\n\n<\/code><\/pre>\n<p>I was testing the result with an oscilloscope and I was getting the following:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine-300x153.png\" alt=\"\" width=\"600\"  class=\"alignnone size-medium wp-image-6285\" srcset=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine-300x153.png 300w, https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine-768x392.png 768w, https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine.png 1016w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>This looks very promising indeed!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last post, I have introduced you to the powerful STM32H743VIT6 microcontroller. Now it is time to test some audio output. I don&#8217;t have any special implementation for the output of analog audio for the STM32H7, but I decided to try to use my generic implementation that is part [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6285,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20,22],"tags":[47],"class_list":["post-6284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound","tag-stm32h7"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Analog Audio Output on an STM32H7 - Phil Schatzmann<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Analog Audio Output on an STM32H7 - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"In my last post, I have introduced you to the powerful STM32H743VIT6 microcontroller. Now it is time to test some audio output. I don&#8217;t have any special implementation for the output of analog audio for the STM32H7, but I decided to try to use my generic implementation that is part [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-30T08:06:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-30T19:49:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1016\" \/>\n\t<meta property=\"og:image:height\" content=\"519\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"pschatzmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pschatzmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Analog Audio Output on an STM32H7\",\"datePublished\":\"2024-07-30T08:06:21+00:00\",\"dateModified\":\"2024-07-30T19:49:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/\"},\"wordCount\":120,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2024\\\/07\\\/sine.png\",\"keywords\":[\"STM32H7\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/\",\"name\":\"Analog Audio Output on an STM32H7 - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2024\\\/07\\\/sine.png\",\"datePublished\":\"2024-07-30T08:06:21+00:00\",\"dateModified\":\"2024-07-30T19:49:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2024\\\/07\\\/sine.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2024\\\/07\\\/sine.png\",\"width\":1016,\"height\":519},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2024\\\/07\\\/30\\\/analog-audio-output-on-an-stm32h7\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Analog Audio Output on an STM32H7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\",\"name\":\"Phil Schatzmann Consulting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\",\"name\":\"pschatzmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"width\":305,\"height\":305,\"caption\":\"pschatzmann\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Analog Audio Output on an STM32H7 - Phil Schatzmann","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/","og_locale":"en_US","og_type":"article","og_title":"Analog Audio Output on an STM32H7 - Phil Schatzmann","og_description":"In my last post, I have introduced you to the powerful STM32H743VIT6 microcontroller. Now it is time to test some audio output. I don&#8217;t have any special implementation for the output of analog audio for the STM32H7, but I decided to try to use my generic implementation that is part [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/","og_site_name":"Phil Schatzmann","article_published_time":"2024-07-30T08:06:21+00:00","article_modified_time":"2024-07-30T19:49:36+00:00","og_image":[{"width":1016,"height":519,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine.png","type":"image\/png"}],"author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Analog Audio Output on an STM32H7","datePublished":"2024-07-30T08:06:21+00:00","dateModified":"2024-07-30T19:49:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/"},"wordCount":120,"commentCount":2,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine.png","keywords":["STM32H7"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/","url":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/","name":"Analog Audio Output on an STM32H7 - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine.png","datePublished":"2024-07-30T08:06:21+00:00","dateModified":"2024-07-30T19:49:36+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2024\/07\/sine.png","width":1016,"height":519},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2024\/07\/30\/analog-audio-output-on-an-stm32h7\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Analog Audio Output on an STM32H7"}]},{"@type":"WebSite","@id":"https:\/\/www.pschatzmann.ch\/home\/#website","url":"https:\/\/www.pschatzmann.ch\/home\/","name":"Phil Schatzmann Consulting","description":"","publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pschatzmann.ch\/home\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1","name":"pschatzmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","width":305,"height":305,"caption":"pschatzmann"},"logo":{"@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png"}}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/comments?post=6284"}],"version-history":[{"count":9,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6284\/revisions"}],"predecessor-version":[{"id":6315,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/6284\/revisions\/6315"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/6285"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=6284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=6284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=6284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}