Author Topic: Help to resolve D/A Converter  (Read 2036 times)

0 Members and 1 Guest are viewing this topic.

Offline alizare368Topic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: de
Help to resolve D/A Converter
« on: July 06, 2019, 12:06:57 pm »
Hi
I used CS4344 sound codec for making the wave player,and it works well,but it has a problem,I have to disconnect and then connect one of the output to start reading,Or activating the output.

Shematic is in the attachment.


this is my code:
Code: [Select]
int main(void)
{
 MX_GPIO_Init();
  MX_DMA_Init();
  MX_I2S2_Init();
  MX_SDIO_SD_Init();
  MX_FATFS_Init();
res=f_mount(&SDFatFs, (TCHAR const*)SDPath, 0);
if(res==FR_OK)
{
res=f_open(&MyFile, "2.wav",FA_READ);
if(res==FR_OK)
{
f_read(&MyFile,&sai_buf[0],sample_no*2,&br);
f_read(&MyFile,&sai_buf[1],sample_no*2,&br);
}

}

index_buf++;
HAL_I2S_Transmit_DMA(&hi2s2,sai_buf[0],sample_no);

while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */

if(refill)
{
refill=0;
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_5,GPIO_PIN_SET);
res=f_read(&MyFile,&sai_buf[index_buf%2],sample_no*2,&br);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_5,GPIO_PIN_RESET);
}

  }

}

void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
{

  HAL_I2S_Transmit_DMA(&hi2s2,sai_buf[index_buf%2],sample_no);
index_buf++;
refill=1;
}

someone know what the problem is?? |O
 

Offline Andy Watson

  • Super Contributor
  • ***
  • Posts: 2340
Re: Help to resolve D/A Converter
« Reply #1 on: July 06, 2019, 12:22:14 pm »
"CONNECT TO HEADPHONE"  ?

The datasheet shows a 3.3\$\mu\$F between the chip and the (pressumably) low impedance headphone. I would guess that  the chip is waiting to see this capacitance charge up - which will never happen if you've connected the heaphone(s) directly.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17818
  • Country: fr
Re: Help to resolve D/A Converter
« Reply #2 on: July 06, 2019, 01:54:19 pm »
Yeah this DAC is absolutely NOT designed to directly drive headphones. :wtf: Besides, its outputs are DC-biased so they require series output caps. See p.15 of the datasheet. Without series output caps, it won't work properly.

See p.11 of the datasheet for a typical output filter stage. And add a small headphones amplifier if you're going to use headphones.
 

Offline alizare368Topic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: de
Re: Help to resolve D/A Converter
« Reply #3 on: July 06, 2019, 02:12:18 pm »
Tanks for help me.
I put the filter in the output and answered. :-+
 

Offline alizare368Topic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: de
Re: Help to resolve D/A Converter
« Reply #4 on: July 10, 2019, 02:38:46 pm »
Hi
I want this program execute with RTOS but when it run ,the program enter this function ( void HardFault_Handler(void) ) and doesn't exit.

Heap size :0x4096
Stak size : 0x4096

os_stak size (words): 1048


Code: [Select]
void HardFault_Handler(void)
{
  /* USER CODE BEGIN HardFault_IRQn 0 */

  /* USER CODE END HardFault_IRQn 0 */
  while (1)
  {
    /* USER CODE BEGIN W1_HardFault_IRQn 0 */
    /* USER CODE END W1_HardFault_IRQn 0 */
  }
}

someone know?? :-X :-X

 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3671
  • Country: gb
Re: Help to resolve D/A Converter
« Reply #5 on: July 10, 2019, 03:25:03 pm »
Tracing the cause of hard faults can be difficult, but is very often caused (IME) by uninitialised pointers or unaligned memory access.  It seems like you are using an Arm cortex micro (you haven't actually said), in which case the stack frame holds some useful debugging information.  Read up on hard fault handling.
 
The following users thanked this post: alizare368

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17818
  • Country: fr
Re: Help to resolve D/A Converter
« Reply #6 on: July 10, 2019, 03:26:58 pm »
I suggest the following reading: https://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html

Edit: oops, sorry, didn't check that mikerj's link was exactly the same!  ;D
« Last Edit: July 10, 2019, 03:31:44 pm by SiliconWizard »
 
The following users thanked this post: alizare368


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->