GitJer / Some-Sipeed-MAIX-GO-k210-stuff

45 stars 14 forks source link

audio out: audio chip powered off by default, if output 32 not set to high #1

Closed spblinux closed 5 years ago

spblinux commented 5 years ago

Your MAIX-GO code snippets are very useful! When trying pcm_play_happy and looking at schematic of maix-go I noticed that the audio out amplifier has to be enabled by setting IO32 to high. E.g. like that:

--- main.c.orig>2019-05-26 00:28:54.000000000 +0200
+++ main.c<---->2019-05-31 23:55:59.000000000 +0200
@@ -21,6 +21,7 @@
 #include "i2s.h"
 #include "sysctl.h"
 #include "fpioa.h"
+#include "gpio.h"
 #include "uarths.h"
 #include "math.h"
.
@@ -191,7 +192,10 @@
     fpioa_set_function(34, FUNC_I2S0_OUT_D1);
     fpioa_set_function(35, FUNC_I2S0_SCLK);
     fpioa_set_function(33, FUNC_I2S0_WS);
-
+    fpioa_set_function(32, FUNC_GPIO0); // power on audio amplifyer
+    gpio_init();
+    gpio_set_drive_mode(0, GPIO_DM_OUTPUT);
+    gpio_set_pin(0, GPIO_PV_HIGH);.
     // It doesn't seem to matter which of the following two bits are 1:
     // 11000000(0xC0), 00110000(0x30), 00001100(0x0C), 00000011(0x03).
     // Two bits indicate stereo sound (I think) but only one channel is actually.
GitJer commented 5 years ago

According to the schematic you are right. But it doesn't seem to matter on my board. I can set 32 high or low, it still works the same. There are two versions of the MaixGo, see here. I have the older Indigogo version. In the schematic of my version pin 32 is not connected to the amplifier. The newer version has some modifications on the PA. That board probably does need 32 to be set.

I will update the code. Thanks!