本帖最后由 55-366289 于 2018-6-14 16:30 编辑
本人萌新
用STM32F4DISCOVERY的示例程序修改存储方式为内部FLASH存储,现在读到的不对,是我的存储方式有问题吗?请大神指教:下面是录音过程和IIS中断采集程序。
- void WaveRecorder_kaishi(void)
- {
- WaveRecorderInit(32000,16, 1); //录音初始化 32KHZ 16位数据 单通道
- WaveCounter = 0;
- LED_Toggle = 7;
- num_shu=0;
-
- STMFLASH_CACHU(); //整片擦除的是地址0x0802 0000 - 0x0803 FFFF 和 0x0804 0000 - 0x0805 FFFF 两个扇区
- /* Start the record 开始录音*/
- WaveRecorderStart(RecBuf, PCM_OUT_SIZE);
-
- /* Reset the time base variable重置时间基变量 */
- Time_Rec_Base = 0;
- Switch = 0;
-
- while(1)
- {
- /* Wait for the recording time 等待录音时间 */
- if (num_shu*32 < 262144)
- {
- /* Wait for the data to be ready with PCM form 等待数据以PCM的形式准备好*/
- while(Data_Status == 0);
- Data_Status =0;
- LED_Toggle = 3;
- if (Switch ==1)
- {
- pAudioRecBuf = RecBuf;
- writebuffer = RecBuf1;
- WaveCounter += 32;
- Switch = 0;
- }
- else
- {
- pAudioRecBuf = RecBuf1;
- writebuffer = RecBuf;
- WaveCounter += 32;
- Switch = 1;
- }
-
- for (counter=0; counter<16; counter++)
- {
- LED_Toggle = 3;
- if (buf_idx< RAM_BUFFER_SIZE)
- {
- /* Store Data in RAM buffer */
- RAM_Buf[buf_idx++]= *(writebuffer + counter);
- if (buf_idx1 == RAM_BUFFER_SIZE)
- {
- buf_idx1 = 0;
- /* Write the stored data in the RAm to the USB Key 将存储的数据写入到USB密匙中 */
- STMFLASH_Write(0x08020000+(num_shu*32),(uint32_t*)RAM_Buf1,RAM_BUFFER_SIZE/2);
- }
- }
- else if (buf_idx1< RAM_BUFFER_SIZE)
- {
- /* Store Data in RAM buffer 在RAM缓冲器中存储数据 */
- RAM_Buf1[buf_idx1++]= *(writebuffer + counter);
- if (buf_idx == RAM_BUFFER_SIZE)
- {
- buf_idx = 0;
- /* Write the stored data in the RAM to the USB Key */
- STMFLASH_Write(0x08020000+(num_shu*32),(uint32_t*)RAM_Buf,RAM_BUFFER_SIZE/2);
- }
- }
- }
-
- }
- else /* End of Recording time 记录结束时间 */
- {
- WaveRecorderStop();
- LED_Toggle = 4;
- luyin = 2;
- Data_Status =0;
- AUDIO_SZE=262144;
- break;
- }
- }
-
-
- void AUDIO_REC_SPI_IRQHANDLER(void)
- {
- u16 volume;
- u16 app;
- /* Check if data are available in SPI Data register 检查SPI数据寄存器中的数据是否可用 */
- if (SPI_GetITStatus(SPI2, SPI_I2S_IT_RXNE) != RESET)
- {
- app = SPI_I2S_ReceiveData(SPI2);
- InternalBuffer[InternalBufferSize++] = HTONS(app);
-
- /* Check to prevent overflow condition 检查防止溢出条件 */
- if (InternalBufferSize >= INTERNAL_BUFF_SIZE)
- {
- InternalBufferSize = 0;
-
- volume = 50;
-
- PDM_Filter_64_LSB((uint8_t *)InternalBuffer, (uint16_t *)pAudioRecBuf, volume , (PDMFilter_InitStruct *)&Filter);
- Data_Status = 1; //代表PDM转PCM转换完毕
- num_shu++;
- }
- }
- }
复制代码
|
谢谢,已经搞定了
评分
查看全部评分
我也在做这个,用单片机读到MIC的数据一直为0x00;你的源码在哪里下载的,我一直没找到,,能分享一下吗?QQ2629286552 拜托了
Demo源代码哪里下载呢?谢谢。