2013-04-25 11:46 AM
Hello,
I am a first time poster on this forum so please bear with me. I am using CMSIS to get the DAC peripheral to play a simple tune. I am working off an example I found online which I have simplified to play only one note (single tone) before moving on to the tune. I am able to build the target, however, when I download it onto the micro-controller, nothing happens. It was suggested to me that this may be due to my not having set a frequency to the DAC, specifically one that would be audible to the human ear. If this is the case, I am curious why this was not touched upon in the example provided and why it is not mentioned in the DAC peripheral files (.c, .h) in CMSIS? Furthermore, I was under the impression that the timer trigger that I've used (see attached) would dictate the frequency of the tone. Is this not the case? If the issue I am having is not related to frequency, I would appreciate any advice that could point me in the right direction. I've included a zip of the working example I found online as well as the main.c file of the code I used to implement my design. The rest is just standard CMSIS that I found on the site. Any help would be greatly appreciated. Thanks in advance, Yusif Nurizade #stm32f4discovery-dac-audio #cmsis-keil-peripheral-library2013-04-25 01:09 PM
You definitely don't want to exit main(), this will crash the processor, as it exits to nowhere in particular. This isn't like writing C on a PC with an OS.
You're outputting a singular DC value, measure the pin with a scope or multimeter, try different values, observed change. Will a DC value generate a tone? Well probably not. Wouldn't you want to be generating an AC (w/DC offset) signal, which oscillates to displace the speaker back and forth?2013-04-27 03:37 PM
Clive,
Thanks so much for your response. Thanks especially for pointing out the issue with exit as I hadn't even noticed that. Your advice about the DC value reaffirms the advice that was given to me about adding the frequency. The issue, however, is that I haven't seen anything regarding frequency in the DAC peripheral files in CMSIS nor any relevant commands in the example which i have included. This example has been stripped down but the full version does play a tune. The best I could think of was that the TIMER6 would impose a frequency but clearly I was mistaken. I will definitely try to read the pin with a multimeter for starters. In the meantime, can anyone suggest where I can find the relevant commands to set frequency or what they could be in order to bring the output into the audible range? Thanks again for the advice, Yusif Nurizade2013-04-27 03:55 PM
You should probably go back an review the original example.
The purpose of TIM6 is to pace the samples sent to the DAC. The period/prescaler control the FREQUENCY with which this occurs. The DAC triggers a DMA transfer, and the DMA is set up to send a wave form to the DAC output register. The table is made up of a sine wave that has it's range spread over the range of the DAC output range. This would be how you control the AMPLITUDE of the signal. The data in the SINE table can represent one or more cycles, one is probably sufficient for a singular tone, but you could mix several tones together. If the table contains 100 values, then the frequency in the TIM6 needs to x100 the frequency to achieve the output frequency.