Skip to main content
Explorer
December 13, 2024
Solved

JTAG signals on STM32L433 [RESOLVED]

  • December 13, 2024
  • 2 replies
  • 1316 views

Hello,
for the project I am developing I am using a STM32L433.
We have connected a motor encoder signals to PA15 and PB3, that are CH1 and CH2 for timer1 TIM2 configured in encoder mode.
We used CubeMX to configure the HW, and that worked perfectly for another encoder on other pins.
We use a ST link HW interface for FW run/debug, using the SWD interface.

I have a problem with the encoder in timer1 to count while the motor is spinning in some cases.

Compiled both in release mode or debug mode and running it or debugging it the FW shows a random behavior with the timer1 often not counting the encoder signals. Behavior may change after a reset or a power on/off cycle.
I have verified that in all cases the input signal is received correctly by periodically reading one of encoder signal status and driving a LED accordingly. If I manually spin the motor the LED blinks, which means the toggling signals are correctly received by the microprocessor. But the timer1 cannot count them.

As we have no problems with the other encoder on timer2 TIM1, we suspect that the problem lies in the multiplexing of signals PA15 and PB3 with JTAG JTDI and JTDO functionality. I have gone through the manual but beside the table describing the JTAG signals pin allocation, there not a description on how to disable them. CubeMX generated code seems not to address this problem.
I have also looked on the forums and the proposed solution seems to use this macro:
__HAL_AFIO_REMAP_SWJ_NOJTAG();

Unfortunately for this microprocessor I cannot find this macro anywhere.
And there's also no AFIO register to directly bit bang.

So how can I disable the JTAG functionality and have the PA15 and PB3 signals be directed to timer1 TIM2 instead of the JTAG controller?

Thanks in advance

Mauro

    This topic has been closed for replies.
    Best answer by MauroF

    Ok, sorry for the question.

    The problem seemed to be in another part of the code where the Timer, after being correctly configured, was NOT  (always) turned on.

    What I have learnt with this issue is that with this L4 micro there's nothing more than to configure the AF functionality to disable the JTAG multiplexing.

     

    Thanks again

    Mauro

     

    2 replies

    Graduate II
    December 14, 2024

    Exactly which STM32L433 are you using?

    I've looked at the STM32L433CB, STM32L433RB, and STM32L433VC.

    PB3 and PA15 don't have TIM1 Channels, only TIM2 Channels exist on those pins.

    MauroFAuthor
    Explorer
    December 16, 2024

    Hello,

    the exact model of the micro is STM32L433VCT6

    And you are right, those signal are tied to TIM2, not one.I'm going to correct the post. Thanks.

    We have another encoder tied to TIM1 and that works without problems.

    Mauro

     

    Graduate
    December 16, 2024

    Have you looked at the Reference Manual for your stm32?

    That has a chapter on General-purpose I/Os (GPIO) that describes the alternate function register e.g. GPIOA->AFRH, bits 28 to 31 of which control which alternate-function controls a PA15 when the PA15 is set to be controlled by an alternate-function.

    And then GPIOA->MODER has bits 30 and 31 controlling whether the pin is GPIO digital input, GPIO digital output, tied to alternate-function, or analog input.

    The next question is which AF0 to AF15 corresponds to which peripheral (including JTAG), and the table if this is in the data sheet for your stm32, in a couple of tables at the end of the "Pinouts and Pin Description" chapter.

    I do wish ST would highlight the Reference Manual more strongly; it is an excellent reference with a huge amount of vital information, but sadly that can make it feel overwhelming at first.

    MauroFAuthorAnswer
    Explorer
    December 16, 2024

    Ok, sorry for the question.

    The problem seemed to be in another part of the code where the Timer, after being correctly configured, was NOT  (always) turned on.

    What I have learnt with this issue is that with this L4 micro there's nothing more than to configure the AF functionality to disable the JTAG multiplexing.

     

    Thanks again

    Mauro

     

    Technical Moderator
    December 16, 2024

    Hello @MauroF ,

    Instead of modifying the title and add [Solved/Resolved] better to mark the comment that answered your question Accepted as Solution.