2020-01-01 04:48 PM
Hi Everyone. I have a question relating to my project, and I think I have it tracked down to one problem area. As a hobbyist, I don’t get the time to work on my projects as someone working in the Industry does, and figuring it all out take so much longer and I hope someone has had experience with my problem.
I'm working through a project I started some months ago and its evolving every time I can get the chance to work on it.
I’m modifying an audio example project "Audio_playback_and_record" for the STM32F4-Discovery board. I especially like that this example project reads and writes to FatFs WAV file stored on a USB drive attached to the STM32F4-Discovery boards Host USB port..
I have an electret microphone connected to a simple pre-amp feeding into an ADC input and it works fine when I use TIM2 to trigger the ADC at 44100 Hz, and within the ADC ISR I can collect a bunch of sampled data and work with it. “Yes I know, there is an on board MEMS�?.
I now want to oversample at approx 780Khz and decimate to 44.1Khz to get 14bits from the 12bit ADC, and I want to use the DMA to collect the data samples and on every HAL_ADC_ConvCpltCallback() callback function I can again work on the sampled data and then store it to a WAV file located on the USB drive.
My problem seems to be when I start the ADC and DMA transfers, it all just stops after a couple of samples and I cant seem to work out why. I initially thought it was a NVIC priority issue because some times I would get an error indicating the USB stick had been removed, but after playing around with these setting I am still having the same problem.
Single stepping through my code reveals the area I thing the issue occurs which is when I want to restart the ADC and DMA for example: ADC_Start_DMA(&hadc3, (uint32_t*)ADC_ConvertedValue, 16);
but the debugger freezes giving no indication why?
I have assembled a test case where I don’t initialize the USB On the Go functions and don’t write the data to disk but I still run the ADC and DMA, oversampling as before, and in this case it works fine. I can’t be certain but when I do initialize the USB functionality but do NOT allow USBH_Process(&hUSB_Host); to run, and so don’t attempt to write to file, the test case appears to work? As soon as I allow the complete USB initialization and enumeration to take place, it all stops again? “This is how its behaving now�? but I’m not sure if this behavior is a consequence of the way I have my code set up. Yes I’m confused!
Thanks
M.B