找回密码
 立即注册
楼主: 梁***

STC32G8K64有硬件I2S,接外部Audio-DAC播放音乐

[复制链接]

该用户从未签到

46

主题

2934

回帖

6617

积分

超级版主

积分
6617
 楼主| 发表于 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就可以输出声音了。
回复 支持 反对 送花

使用道具 举报

该用户从未签到

4

主题

85

回帖

646

积分

高级会员

积分
646
发表于 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 ?
回复 支持 反对 送花

使用道具 举报

该用户从未签到

4

主题

85

回帖

646

积分

高级会员

积分
646
发表于 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/docume ... r-Directive?lang=en

Examples       
Command line :  C51 SAMPLE.C CD
Source code :    #pragma code
回复 支持 反对 送花

使用道具 举报

该用户从未签到

4

主题

85

回帖

646

积分

高级会员

积分
646
发表于 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 generate  21.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


回复 支持 反对 送花

使用道具 举报

该用户从未签到

550

主题

9318

回帖

1万

积分

管理员

积分
13898
发表于 2023-6-13 07:08:06 | 显示全部楼层

STC32F12K54-64MHz-LQFP48, LQFP32, TSSOP20
1.png

2.png

3.png

4.png

5.png

http://www.stcmcudata.com/STC8F-DATASHEET/STC32F12K54.pdf
1.png



回复 支持 1 反对 0 送花

使用道具 举报

  • TA的每日心情
    开心
    2024-3-13 15:49
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    0

    主题

    12

    回帖

    454

    积分

    中级会员

    积分
    454
    发表于 2023-6-13 14:07:24 | 显示全部楼层
    STC32G8K64  有硬件I2S,是可以直接外部播放器吗?单片机再可以输出PWM信号吗?

    点评

    STC32G8K64有144MHz时钟8通道16位高级PWM。 有I2S接I2S接口的DAC直接播放音频,可以到CD音质,44.1KHz采样立体声。  详情 回复 发表于 2023-6-13 15:40
    回复 支持 反对 送花

    使用道具 举报

    该用户从未签到

    46

    主题

    2934

    回帖

    6617

    积分

    超级版主

    积分
    6617
     楼主| 发表于 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采样立体声。
    回复 支持 反对 送花

    使用道具 举报

    该用户从未签到

    4

    主题

    85

    回帖

    646

    积分

    高级会员

    积分
    646
    发表于 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 ?

    回复 支持 反对 送花

    使用道具 举报

    该用户从未签到

    2

    主题

    8

    回帖

    56

    积分

    注册会员

    积分
    56
    发表于 2023-6-14 13:44:57 | 显示全部楼层
    国学芯用 发表于 2023-6-2 08:50
    这是我们的一个需求框图   MCU将存在FLASH(内置或者外置)的内容通过CODEC解码后给AMP

    请STC专家帮忙评估 ...

    MP3 通过DAC输出声音吗?
    回复 支持 反对 送花

    使用道具 举报

    该用户从未签到

    2

    主题

    8

    回帖

    56

    积分

    注册会员

    积分
    56
    发表于 2023-6-14 13:46:15 | 显示全部楼层
    梁工 发表于 2023-6-2 10:30
    STC32G8K64、STC32F系列的I2S只能工作于主模式,并且只有一个通道,所以只能接DAC,不能接CODEC(这个要 ...

    将MP3 通过DAC 输出声音吗?

    点评

    MP3是复杂压缩方式,要解压缩才可以得到WAV。MCU不能软解MP3,算力不够。ARM M3算力都不够。  详情 回复 发表于 2023-6-14 18:35
    回复 支持 反对 送花

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

    GMT+8, 2024-5-5 10:03 , Processed in 0.082456 second(s), 71 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表