梁工
发表于 2023-6-2 10:30:12
国学芯用 发表于 2023-6-2 08:50
这是我们的一个需求框图 MCU将存在FLASH(内置或者外置)的内容通过CODEC解码后给AMP
请STC专家帮忙评估 ...
STC32G8K64、STC32F系列的I2S只能工作于主模式,并且只有一个通道,所以只能接DAC,不能接CODEC(这个要一个主I2S一个从I2S)。
其余没问题,MCU读FLASH,送给DAC就可以输出声音了。
jmg
发表于 2023-6-13 05:34:11
STC32F12K54 has hardware I2S, connected to an external Audio-DAC to play music
How fast is the FPU inside STC32F ?
How quickly can it calculate sine(x) and scale to feed to I2S, to give real time sine wave generate ?
jmg
发表于 2023-6-13 06:14:55
I2S test program.zip
Good examples, can I request you add Assembler listing to the compiler output, for the simple example programs. The ZIP has .LST file, but it is C-Source without assembler generated.
It is easy to get assembler information added to LST file :
https://developer.arm.com/documentation/101655/0961/Cx51-User-s-Guide/Compiling-Programs/Directives/Reference/CODE-Compiler-Directive?lang=en
Examples
Command line :C51 SAMPLE.C CD
Source code : #pragma code
jmg
发表于 2023-6-13 06:45:46
本帖最后由 jmg 于 2023-6-13 07:35 编辑
zxy Posted on 2023-3-3 16:23
Can this MCU generate a sine wave with a lower frequency, such as 50-400HZ?
In the example 02 with SineTable.h, there is a simple ROM lookup example with 32 entries.
With the 44100 sample rate and a larger table, you can go lower in frequency
eg 44100/2048 will generate21.53320312Hz sine.
44100/512 = 86.1328125Hz etc
Binary sized tables are not essential, you can create a table in XRAM and run-time fill it and change the size at run-time, for many more frequencies.
eg a XDATA Table 882 values in size, gives 44100/882 = 50.000Hz
The next step in Hz here is 44100/881 = 50.05675369Hz
For 400Hz you check 44100/400= 110.25, not an integer, so options are
a) 44100/110 = 400.9090909Hz
or, you could
b) create 4 full sine cycles fitted into 441 values table, or 8 full cycles into 882 values table, for 400.00Hz
The larger table with 882 values, gives you a next-step of 8*44100/881 = 400.4540295Hz
Each time you change mm.nn Hz, you recalculate the table size, and recalculate the values and re-fill the table.
addit: Or, you can run a DDS adder inside the I2S interrupt, and use a fixed Sine table (say 256 bytes) indexed with the upper 8 bits of the adder.
Above 44100/256 = 172.265625Hz, the DDS skips some different values for every sine, and below that some values duplicate.
The average, filtered sine is always the correct calculated Hz.
Examples with a simple 16 bit DDS adder are
44100*594/2^16= 399.710083 Hz
44100*595/2^16= 400.3829956Hz
44100*74/2^16 = 49.79553223Hz
44100*75/2^16 = 50.46844482Hz
神农鼎
发表于 2023-6-13 07:08:06
STC32F12K54-64MHz-LQFP48, LQFP32, TSSOP20
http://www.stcmcudata.com/STC8F-DATASHEET/STC32F12K54.pdf
yzq_1324606
发表于 2023-6-13 14:07:24
STC32G8K64有硬件I2S,是可以直接外部播放器吗?单片机再可以输出PWM信号吗?
梁工
发表于 2023-6-13 15:40:18
yzq_1324606 发表于 2023-6-13 14:07
STC32G8K64有硬件I2S,是可以直接外部播放器吗?单片机再可以输出PWM信号吗? ...
STC32G8K64有144MHz时钟8通道16位高级PWM。
有I2S接I2S接口的DAC直接播放音频,可以到CD音质,44.1KHz采样立体声。
jmg
发表于 2023-6-14 03:49:07
神农鼎 发表于 2023-6-13 07:08
STC32F12K54-64MHz-LQFP48, LQFP32, TSSOP20
Thanks, I searched the DOCs for 'FPU', which gives sparse hits,and missed the FPMU info.
Those numbers suggest there may be time to calculate a real-time scaled sin(x), at least at the slowest 44100 ballpark speed.
It's unlikely to be fast enough to calculate at highest possible DAC 192k sample rates ?
There are probably issues around using float inside interrupts, so this may need a paced buffer fill and DMA from the buffer to the i2s ?
13430409025
发表于 2023-6-14 13:44:57
国学芯用 发表于 2023-6-2 08:50
这是我们的一个需求框图 MCU将存在FLASH(内置或者外置)的内容通过CODEC解码后给AMP
请STC专家帮忙评估 ...
MP3 通过DAC输出声音吗?
13430409025
发表于 2023-6-14 13:46:15
梁工 发表于 2023-6-2 10:30
STC32G8K64、STC32F系列的I2S只能工作于主模式,并且只有一个通道,所以只能接DAC,不能接CODEC(这个要 ...
将MP3 通过DAC 输出声音吗?