cancel
Showing results for 
Search instead for 
Did you mean: 

JTAG and use of GPIO

russ
Associate II
Posted on June 19, 2008 at 02:43

JTAG and use of GPIO

5 REPLIES 5
russ
Associate II
Posted on May 17, 2011 at 12:37

Can you utilize the JTAG pins as GPIO and still have JTAG programming functionality? Or once JTAG is enabled do you loose the I/O dedicated to those JTAG pins?

jj
Associate II
Posted on May 17, 2011 at 12:37

''Stealing'' the pins from JTAG to GPIO functionality can be done but requires caution.

Here's a procedure which works for my group: (recall that these pins always default to JTAG use upon Reset - your code then reformats these to GPIO - which removes their JTAG functionality)

A)we NEVER assume that product is ''done'' - we can thus ''grab'' JTAG and use it as GPIO! For safety - and to allow reclaim of JTAG - we implement a small GPIO, ADC or Timer routine which looks for an ''unlikely'' condition shortly after Reset. If this condition is met - we ''bypass'' the code block which converts JTAG pins to GPIO - thus in ''normal'' operation we can employ these pins as GPIO. However when the ''switch, ADC level or Timer'' is unique - we restore JTAG and prevent GPIO reformat.

B) this method ''frees'' these pins for GPIO yet still allows us the joy of debug via the hi-speed JTAG or SWD. However - you cannot ''run'' your program from within the debugger after JTAG to GPIO ''switch.'' The debugger/IDE will not be able to re-establish commo with your STM32 until'

Reset - when your ''unique'' condition is met.

C) the implication of this seems to be that you should develop and test any challenging code on ''other - NON-JTAG'' pins first to confirm that your code is good. After you're happy - you can reconfigure your code to match the JTAG pins - program your part - and observe performance ''live.''

Be sure to check that your JTAG-GPIO switching code block/logic really works before implementing it. Suggest that you test via Led - only reconfigure the JTAG when you have confidence.

Attended STM32 Seminar (2nd time in year) today and learned that SWD has very similar performance to JTAG - AND surprising benefits. (such as TRACE!) As SWD uses fewer pins perhaps you should switch to this - this will - in itself - give you additional GPIO pins without the ''switch-test'' requirement outlined earlier.

Hope this helps - plz let the forum know how you progress...

russ
Associate II
Posted on May 17, 2011 at 12:37

Thank you so much for you help. I will definitely look at SWD and I'll note my progress as I go.

russ
Associate II
Posted on May 17, 2011 at 12:37

I just had an idea: what if I put in a 10 second delay after reset when I first run the code before making the JTAG->GPIO switch. With this in place I can always reprogram and grab hold of the JTAG pins before they are no longer JTAG functional.

jj
Associate II
Posted on May 17, 2011 at 12:37

Your 10 sec will work - but will drive you ''nutz'' while waiting for your code to run. Use shorter delay - or use a single, momentary switch which forces JTAG - when the switch is active. Simply engage this switch upon reset to force into JTAG mode.

*** We find that during ''major'' debug it is better to default the switch so that you must do something ''unique'' to switch from JTAG to GPIO. This way every debug session will enable JTAG (with NO action required on your part). Once you've got everything going - be sure to change this JTAG/GPIO switch function to operate in ''reverse.'' (so that you have to do ''something'' to recover JTAG)