cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Discovery: Trying to trigger ADC conversion with Timer, How to Debug?

bryan23
Associate II
Posted on December 05, 2012 at 21:33

Hi all,

Trying to trigger ADC conversion with a Timer, (8 kHz, to be exact).

Without doing an annoying,12 page code dump here, how can I debug my app to make sure the Timer event is triggering the ADC conversion? I'm very new to debugging on this platform, so be gentle. Thanks.

Edit: By debug, I mean, how can I look into the chip to see which flags are set for the ADC. I am thinking I could check the ADC status flag to see if it has performed, or is currently performing a conversion, but is there also a way to see the timer event firing? Do I just view the memory location of the ADC status register? I'm kinda looking for a platform independent answer, but for what its worth, I'm currently using Keil uVision4.
5 REPLIES 5
Posted on December 05, 2012 at 21:58

8 KHz is going to be a bit of a bugger to do by eye.

You could look at the TIM channel outputs directly on the pins with a scope.

You could reflect register bits to external pins/LEDs.

You could catch the EOC interrupt from the ADC, toggling a pin in response.

You could DMA out of the ADC into memory, and park a memory view/watch window over it.

You could output telemetry via the serial port. Monitoring locations, registers, counts, etc.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
bryan23
Associate II
Posted on December 05, 2012 at 22:36

Thanks for that quick response!  I've verified my timer is firing at 8 kHz by toggling an LED in the timer interrupt handler and putting a scope on it. Yes, I know that means my LED is blinking at 4 kHz 😉 

Your list of suggestions got me thinking of some things to try out.

Quick question on your serial port comment...can I just printf and have info appear in my IDE console? From what I understand, ARM debugging used properly can be quite powerful, and printf's are the clear sign of King N00b, but if its a starting point, whatever works works.

Thanks again.

Posted on December 06, 2012 at 01:53

Well you can certainly retarget the printf/putchar functions to use a serial port. The ARM9 parts had a DCC (Debug Com Channel), and the M3 has a SWV, although I've had kind of mixed results with the latter, and support for it on various debug pods.

http://www.keil.com/download/files/swv_on_cortex-m3.pdf

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32VLDiscovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32VLDiscovery/Auto-running%201024%20byte%20program%20from%20flash&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000491D59B8574F8049B5DFA3E8B21CBA51&currentviews=469]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32VLDiscovery/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32VLDiscovery%2FAuto-running%201024%20byte%20program%20from%20flash&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000491D59B8574F8049B5DFA3E8B21CBA51¤tviews=469

See also retarget.c and serial.c examples in some of Keil's sample directories.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
bryan23
Associate II
Posted on December 06, 2012 at 18:05

Cool, thanks again.

BTW, got my issue sorted out. EXTEN[1:0] was never getting set correctly, thereby disabling any external triggering. Looked around a bit thru the ST Library docs and couldn't really find what function/struct parameter sets those bits. Oh, the perils of using someone else's library! :D

bryan23
Associate II
Posted on December 06, 2012 at 19:16

Aaaaaaand I found it now, quite easily actually. What a wonder a cup of coffee will do... 🙂