{"id":416,"date":"2017-11-24T23:13:00","date_gmt":"2017-11-24T22:13:00","guid":{"rendered":"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=416"},"modified":"2019-08-19T22:57:45","modified_gmt":"2019-08-19T20:57:45","slug":"45-cs43l22-library-stm32f4","status":"publish","type":"page","link":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=416","title":{"rendered":"45-CS43L22-Library (STM32F4)"},"content":{"rendered":"<p><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-previous\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=414\" title=\"44-UDP_Server-Library (STM32F4)\"><span class=\"meta-nav\">\u2190<\/span> 44-UDP_Server-Library (STM32F4)<\/a><\/div><\/div><!-- #nav-below --><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-next\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=419\" title=\"46-IRSND-Library (STM32F4)\">46-IRSND-Library (STM32F4) <span class=\"meta-nav\">&rarr;<\/span><\/a><\/div><\/div><!-- #nav-below --><\/p>\n<p>Mit dieser Library kann der Audio-DAC (CS43L22) vom Discovery-Board benutzt werden um WAV-Files aus dem Flash abzuspielen.<br \/>\n<em>(zum abspielen von MP3-Files gibt es eine extra LIB)<\/em><\/p>\n<p>Die WAV-Files m\u00fcssen im 16bit PCM-Format entweder Mono oder Stereo vorliegen. Und es funktionieren Abtastraten von 8kHz bis 48kHz.<\/p>\n<p>Mit meinem PC-Programm \u201c<a href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=140#P03\">FileConverter<\/a>\u201d k\u00f6nnen beliebige WAV-Files in ein C-Format umgewandelt werden um dieses dann im Projekt hinzuf\u00fcgen zu k\u00f6nnen.<\/p>\n<p>Der Header vom WAV-File wird vor dem abspielen gepr\u00fcft und ausgewertet. Falls da was nicht stimmen sollte (z.B. nur 8bit Format) wird eine Fehlernummer zur\u00fcckgeliefert.<\/p>\n<p>Die WAV kann entweder nur einmal \u201csingle\u201d oder endlos \u201cloop\u201d abgespielt werden. Es gibt noch Funktionen f\u00fcr Pause, Resume, Stop und Volume.<\/p>\n<p>Hinweis : Der I2S-Clock und der notwendige PLL muss nicht im \u201csystem_stm32f4xx.c-File\u201d eingestellt werden, das wird von der Library erledigt.<\/p>\n<p><strong>Benutzte Pins :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">PB9  = SDA\r\nPB6  = SCL\r\nPA4  = WS\r\nPC7  = MCLK\r\nPC10 = SCK\r\nPC12 = SD\r\nPD4  = Reset<\/pre>\n<p><strong>Voraussetzungen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">Benutzte Module der CooCox-IDE : SPI, DMA, MISC\r\nBenutzte Librarys : STM32_UB_I2C1<\/pre>\n<p><strong>Enumerationen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">typedef enum {\r\n  WAV_OK = 0,        \/\/ WAVE-Header ist ok\r\n  WAV_INIT_ERR,      \/\/ Fehler beim init\r\n  WAV_SIZE_ERR,      \/\/ File zu klein\r\n  WAV_ID_ERR,        \/\/ RIFF-ID fehlt\r\n  WAV_ID2_ERR,       \/\/ WAVE-ID fehlt\r\n  WAV_ID3_ERR,       \/\/ fmt-ID fehlt\r\n  WAV_FMT_LEN_ERR,   \/\/ falsche L\u00e4nge von ftm\r\n  WAV_TYP_ERR,       \/\/ Typ ist nicht PCM\r\n  WAV_CH_ERR,        \/\/ kein Mono oder Stereo\r\n  WAV_FRQ_ERR,       \/\/ Fehler bei Samplefrq\r\n  WAVE_FRAME_ERR,    \/\/ Fehler im Frame\r\n  WAVE_BPS_ERR,      \/\/ Fehler bei Bit per Sample\r\n  WAVE_ID4_ERR       \/\/ DATA-ID fehlt\r\n}WAV_ERR_t;<\/pre>\n<p><strong>Funktionen :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">ErrorStatus UB_CS43L22_Init(void);                                \/\/ init vom CS43L22\r\nWAV_ERR_t UB_CS43L22_PlayWAVSingle(UB_WAV *wav, uint8_t Volume);  \/\/ PLAY (einmal)\r\nWAV_ERR_t UB_CS43L22_PlayWAVLoop(UB_WAV *wav, uint8_t Volume);    \/\/ PLAY (Endlos)\r\nvoid UB_CS43L22_PauseWAV(void);                                   \/\/ PAUSE\r\nvoid UB_CS43L22_ResumeWAV(void);                                  \/\/ WEITER (nach Pause)\r\nvoid UB_CS43L22_StopWAV(void);                                    \/\/ STOP\r\nvoid UB_CS43L22_SetVolume(uint8_t Volume);                        \/\/ zum einstellen der Lautst\u00e4rke<\/pre>\n<p><strong>Beispiel :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">\/\/--------------------------------------------------------------\r\n\/\/ File     : main.c\r\n\/\/ Datum    : 09.06.2013\r\n\/\/ Version  : 1.0\r\n\/\/ Autor    : UB\r\n\/\/ EMail    : mc-4u(@)t-online.de\r\n\/\/ Web      : www.mikrocontroller-4u.de\r\n\/\/ CPU      : STM32F4\r\n\/\/ IDE      : CooCox CoIDE 1.7.0\r\n\/\/ Module   : CMSIS_BOOT, M4_CMSIS_CORE\r\n\/\/ Funktion : Demo der CS43L22 Library\r\n\/\/ Hinweis  : Diese zwei Files muessen auf 8MHz stehen\r\n\/\/              \"cmsis_boot\/stm32f4xx.h\"\r\n\/\/              \"cmsis_boot\/system_stm32f4xx.c\"\r\n\/\/--------------------------------------------------------------\r\n\r\n#include \"main.h\"\r\n#include \"stm32_ub_led.h\"\r\n#include \"stm32_ub_cs43l22.h\"\r\n\r\nint main(void)\r\n{\r\n  ErrorStatus check;\r\n\r\n  SystemInit(); \/\/ Quarz Einstellungen aktivieren\r\n\r\n  \/\/ init der LEDs\r\n  UB_Led_Init();\r\n\r\n  \/\/ init vom CS43L22\r\n  check=UB_CS43L22_Init();\r\n  if(check==SUCCESS) {\r\n    UB_Led_On(LED_GREEN);\r\n    \/\/ abspielen der WAV in einer Endlosloop\r\n    UB_CS43L22_PlayWAVLoop(&amp;m32k16b_wav, 70);\r\n  }\r\n  else {\r\n    UB_Led_On(LED_RED);\r\n  }\r\n\r\n  while(1)\r\n  {\r\n\r\n  }\r\n}\r\n<\/pre>\n<p>Hier die Library zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/wp-content\/uploads\/2013\/06\/ub_stm32f4_cs43l22_v100.zip\">ub_stm32f4_cs43l22_v100<\/a><\/p>\n<p>Hier der komplette CooCox-Projektordner zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/wp-content\/uploads\/2013\/06\/Demo_45_CS43L22.zip\">Demo_45_CS43L22<\/a><\/p>\n<p>Hier das PC-Programm zum umwandeln von WAV-Files in C-Files\u00a0zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/wp-content\/uploads\/2013\/09\/FileConverter_UB_v103.zip\">FileConverter_UB_v103<\/a><\/p>\n<h3 id=\"comments-title\">17 Antworten auf <em>45-CS43L22-Library (STM32F4)<\/em><\/h3>\n<ol class=\"commentlist\">\n<li id=\"li-comment-620\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-620\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/af5be9fa3f95b3ec9c424ed130b7f2d3?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Tobias<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">7. Juli 2013 um 15:32<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hey,<br \/>\ndanke f\u00fcr das tolle Projekt. Deine Demo funktioniert wunderbar.<br \/>\nWenn ich aber selbst ein File einbinde, bleiben die Kopfh\u00f6rer still. Ich habe eine MP3 mit Audacity eingelesen, gek\u00fcrzt und dann als Wave 16-Bit PCM exportiert(44,1kHz Samplerate). Mit deinem Programm problemlos in *.c gewandelt, im Projekt eingebunden und programmiert. Die hex-Daten sehen gut aus, zumindest immer ver\u00e4nderliche Werte und im Betrieb geht auch die gr\u00fcne Led an.<br \/>\nHast du eine Idee, wo ich den fehler mache?<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-621\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-2\">\n<div id=\"comment-621\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">7. Juli 2013 um 17:02<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>schwer zu sagen, sende mir einfach mal das original WAV-File zu, vlt finde ich den Fehler.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-631\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-631\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">8. Juli 2013 um 18:03<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>du hast das Problem ja mittlerweile gel\u00f6st aber hier zur Info. Der WAV-Header von deinem File entspricht nicht dem standard und die Funktion \u201cUB_CS43L22_PlayWAVLoop\u201d wirft eine Fehlermeldung\u2026.die aber bl\u00f6derweise in meinem Beispiel-Programm nicht angezeigt wird <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_smile.gif\" alt=\":-)\" \/> da sollte man vlt. noch den R\u00fcckgabewert auswerten !<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-683\" class=\"comment odd alt thread-odd thread-alt depth-1\">\n<div id=\"comment-683\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/af5be9fa3f95b3ec9c424ed130b7f2d3?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Tobias<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">11. Juli 2013 um 18:58<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Achso, das hatte ich dann auch vermutet. Da ist wohl etwas bei der Umwandlung mp3-&gt;wav schief gelaufen. Danke f\u00fcrs schauen. Die leuchtende gr\u00fcne Led hat mich verwirrt, da sie zu unrecht geleuchtet hat, auch wenn die mit meinem Fehler gar nix zu tun hatte.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-692\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-692\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/1cad00581147329e59667252aaa1b390?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\"><a class=\"url\" href=\"http:\/\/malarchism.wordpress.com\/\" rel=\"external nofollow\">Aud<\/a><\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">17. Juli 2013 um 16:33<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Thank you very much for this (sorry I only know English).<\/p>\n<p>What is the \u201crequired format\u201d for the wave files. I have the same issue as Tobias.<\/p>\n<p>This library is just what I have been looking for<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-695\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt thread-odd thread-alt depth-1\">\n<div id=\"comment-695\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">17. Juli 2013 um 18:13<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>The Sound-File-Format must be \u201cPCM\u201d with no compression, and 16bit per Sample<br \/>\nChannels : mono or stereo, SamplFrq : 8kHz to 48kHz<br \/>\nPlease check the return value of the function \u201cUB_CS43L22_PlayWAVLoop\u201d<br \/>\nto locate an error in the WAV-Header<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-1982\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-1982\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/efe061bcc74a97fb609966b6945fdcb5?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Sidney<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">26. Juli 2014 um 17:57<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hey,<br \/>\nFirst of all thank you for this website, it has greatly improved my understanding of the STM32F4 discovery board.<br \/>\nI\u2019m working on a project where i want to record audio (using the MP45DT02 mic) and save it as a WAV file on a USB stick. After this i want to use the Audio-DAC (CS43L22) to play the recorded file. I have used a combination of Demo_32_USB_MSC_HOST, Demo_47_MP45DT02, Demo_54_USB_MP3 and this one to achieve this. I\u2019m having some trouble with the last step, i don\u2019t know how i can acces the recorded file. Maybe you can help me?<br \/>\nAgain, thanks for everything.<\/p>\n<p>Greetings, Sidney<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1983\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-2\">\n<div id=\"comment-1983\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">28. Juli 2014 um 11:25<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hi, the MP45DT02-Lib saves the audio as WAV-File (not MP3) please test on a first step that this file is ok. You can play it on a pc to verify that. In a second step you have to change the CS43L22-Lib to play the WAV from USB instead of FLash.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2132\" class=\"comment even depth-3\">\n<div id=\"comment-2132\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/efe061bcc74a97fb609966b6945fdcb5?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Sidney<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">10. September 2014 um 16:27<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hey, thanks for the response. Sorry i didn\u2019t reply sooner, but my computer crashed. Right now i have recorded a WAV file on the USB using the UB_MP45DT02_RecordLoop function from the Demo_47_MP45DT02 library. Now i want to use the UB_CS43L22_PlayWAVLoop function to play the recording. The PlayWAVLoop function requires a \u201cUB_WAV\u201d input. I don\u2019t know how i can acces the recording and change it to meet this requirement. Hopefully you can help me with this problem.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-2168\" class=\"comment odd alt depth-3\">\n<div id=\"comment-2168\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/efe061bcc74a97fb609966b6945fdcb5?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Sidney<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">24. September 2014 um 16:11<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hi, please ignore my previous question. Where do i have to change the CS43L22-Lib to play the WAV from USB instead of FLash? Thank you.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2169\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-4\">\n<div id=\"comment-2169\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">25. September 2014 um 18:57<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>please have a look at the function \u201cUB_CS43L22_PlayWAVSingle\u201d<\/p>\n<p>you need to call two functions :<br \/>\n1. UB_AUDIO_InitNew()<br \/>\n2. EVAL_AUDIO_Play()<\/p>\n<p>The \u201cinit\u201d defines the output, volume and samplerate.<br \/>\nThe \u201cplay\u201d plays the wav-file.<\/p>\n<p>But you have to call the play function in a loop<br \/>\nbecouse you must load the wav-file from usb<br \/>\nin little packets so you need a buffer<\/p>\n<pre>char sampl_buf[256];\r\n\r\ndo {\r\n  load_from_usb(sampl_buf,256)\r\n  play_wav(sampl_buf,256)\r\n}while(not eof)\r\n<\/pre>\n<p>like this<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-2192\" class=\"comment odd alt depth-5\">\n<div id=\"comment-2192\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/efe061bcc74a97fb609966b6945fdcb5?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Sidney<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">29. September 2014 um 11:04<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hi, thank you for your answer. I have changed the \u201cUB_CS43L22_PlayWAVSingle\u201d function like you told me, but there is still no sound from the device.<\/p>\n<p>My code:<br \/>\n<code><br \/>\nWAV_ERR_t UB_CS43L22_PlayWAVSingle(uint8_t Volume)<br \/>\n{<br \/>\nWAV_ERR_t ret_wert=WAV_INIT_ERR;<br \/>\nUB_WAV wav_file;<br \/>\nUB_WAV * wav_file_pt;<br \/>\nFATFS_t controle;<br \/>\nFATFS_t buffer_check;<br \/>\nFIL recording;<br \/>\nuint8_t wav_buff[256]=\"0\";<\/code><\/p>\n<p>if((cs43l22_status==CS43L22_INIT_OK) || (cs43l22_status==CS43L22_STOP)) {<br \/>\n\/\/ check vom WAV-Header<\/p>\n<p>wav_start = wav_buff;<br \/>\nwav_file_pt = &amp;wav_file;<br \/>\ncontrole=UB_Fatfs_OpenFile(&amp;recording,&#8220;test16k.wav&#8220;,F_RD);<br \/>\nbuffer_check=UB_Fatfs_ReadBlock(&amp;recording,wav_start,256,wav_file.size);<br \/>\nwav_file.size = UB_Fatfs_FileSize(&amp;recording);<br \/>\nwav_file.table = wav_start;<\/p>\n<p>ret_wert=P_CS43L22_CheckWAV(wav_file_pt);<\/p>\n<p>if(ret_wert==WAV_OK) {<br \/>\ncs43l22_status=CS43L22_PLAY;<br \/>\nwav_loop=0; \/\/ single play<br \/>\nwav_start=wav_file.table[my_wav.data_start];<\/p>\n<p>if(my_wav.channels==2) {<br \/>\n\/\/ stereo<br \/>\nUB_AUDIO_InitNew(OUTPUT_DEVICE_HEADPHONE, Volume, my_wav.samplerate);<br \/>\n}<br \/>\nelse {<br \/>\n\/\/ mono<br \/>\nUB_AUDIO_InitNew(OUTPUT_DEVICE_HEADPHONE, Volume, my_wav.samplerate\/2);<br \/>\n}<br \/>\nUB_Led_On(LED_BLUE);<br \/>\nEVAL_AUDIO_Play((uint16_t*)wav_start, 256);<\/p>\n<p>wav_start = wav_buff;<\/p>\n<p>while(buffer_check!=FATFS_EOF)<br \/>\n{<br \/>\nbuffer_check=UB_Fatfs_ReadBlock(&amp;recording,wav_start,256,wav_file.size);<br \/>\nEVAL_AUDIO_Play((uint16_t*)wav_start, 256);<br \/>\nwav_start = wav_buff;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\nreturn(ret_wert);<br \/>\n}<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-2193\" class=\"comment even depth-5\">\n<div id=\"comment-2193\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/efe061bcc74a97fb609966b6945fdcb5?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Sidney<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">29. September 2014 um 11:24<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Sorry, more readable:<br \/>\n<a href=\"http:\/\/pastebin.com\/ZrRA2wHz\" rel=\"nofollow\">http:\/\/pastebin.com\/ZrRA2wHz<\/a><\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-3986\" class=\"comment odd alt thread-odd thread-alt depth-1\">\n<div id=\"comment-3986\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67ce0c33ddea243162811669b872305b?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Daniel<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">25. Juli 2015 um 00:01<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hallo,<br \/>\nich gebe ein sehr kurzes File wieder: 16 Bit mono 44,1kHz ca. 4000 Werte.<\/p>\n<p>Habe dein Projekt direkt in CoIDE genommen und dann den Inhalt<br \/>\ndeines Audio-Files gegen mein kurzes getauscht.<\/p>\n<p>Nun spielt er erst mein kurzes, dann aber das lange von dir (ist wohl noch im Flash!).<\/p>\n<p>Hab dann trotzdem es in mein Projekt kopiert. Nun st\u00fcrzt nach Aufruf<br \/>\nUB_CS43L22_PlayWAVSingle(&amp;File1, 255);<br \/>\nirgend es ab (es werden Variablen und Ports \u00fcberschrieben\u2026).<\/p>\n<p>Das Audio-File wird fehlerlos erkannt.<\/p>\n<p>Woran k\u00f6nnte das liegen?<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-4010\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-4010\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">27. Juli 2015 um 11:49<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>hast du nur die Daten mit einem Editor ersetzt ?<br \/>\nDu musst dein WAV-File mit meinem <a href=\"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=140#P03\">FileConverter<\/a> in ein C-File<br \/>\nwandeln, damit wird auch die L\u00e4ngenangabe mit gespeichert.<br \/>\nin deinem Fall die 4000 Bytes.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-3987\" class=\"comment odd alt thread-even depth-1\">\n<div id=\"comment-3987\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67ce0c33ddea243162811669b872305b?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Daniel<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">25. Juli 2015 um 00:05<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>ah, \u2013 noch ne Frage<\/p>\n<p>wie kommt die Audio-Datei ins Flash?<\/p>\n<p>Wie geht es, dass direkt aus dem Flash wiedergegeben wird?<br \/>\nGibt es eine Einstellung in CoIDE?<\/p>\n<p>Habe \u201cconst\u201d benutzt, aber dann wird nach Reset nur die const Daten ins RAM<br \/>\nkopiert und dann von dort wiedergegeben.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-4009\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-2\">\n<div id=\"comment-4009\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">27. Juli 2015 um 11:44<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>mit der Angabe \u201cconst\u201d landen die Daten im Flash. 880 kByte w\u00fcrden auch schlecht ins RAM vom F4 passen <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_smile.gif\" alt=\":-)\" \/><\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Mit dieser Library kann der Audio-DAC (CS43L22) vom Discovery-Board benutzt werden um WAV-Files aus dem Flash abzuspielen. (zum abspielen von MP3-Files gibt es eine extra LIB) Die WAV-Files m\u00fcssen im 16bit PCM-Format entweder Mono oder Stereo vorliegen. Und es funktionieren &hellip; <a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=416\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":144,"menu_order":45,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[128],"tags":[160,193,9,7],"class_list":["post-416","page","type-page","status-publish","hentry","category-stm32f4","tag-audio","tag-cs43l22","tag-library","tag-stm32f4"],"_links":{"self":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=416"}],"version-history":[{"count":5,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/416\/revisions"}],"predecessor-version":[{"id":2649,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/416\/revisions\/2649"}],"up":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/144"}],"wp:attachment":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}