This is an automated email from Gerrit.

Adrian M Negreanu ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/5807

-- gerrit

commit 4b30eccdd95a59bbe0892652cf9ba8f68afb4e23
Author: Adrian Negreanu <[email protected]>
Date:   Sun Aug 16 21:37:32 2020 +0300

    drivers/jlink: fix calculate_swo_prescaler formula
    
    a) TPIU_ACPR is defined as:
        SWO_baudrate = TRACECLKIN/(TPIU_ACPR +1)
    
    b) TPIU_ACPR is set by armv7m_trace_tpiu_config()
        target_write_u32(target, TPIU_ACPR, Prescaler-1), so
        TPIU_ACPR = Prescaler-1
    
    Replacing TPIU_ACPR in a), we get:
        SWO_baudrate = TRACECLKIN/Prescaler, so
    
    c)  Prescaler = TRACECLKIN/SWO_baudrate
    
    The Prescaler calculated by calculate_swo_prescaler() is greater by 1:
        Prescaler = TRACECLKIN/SWO_baudrate + 1
    
    The second problem is that even in situations when
    an exact baudrate match is possible,
    the resulting TRACECLKIN/Prescaler already has a 3% deviation.
    
    For example, TRACECLKIN=88000000, SWO_baudrate=500000,
    calculate_swo_prescaler will return Prescaler=171.
    The correct value should be Prescaler=176 (TPIU_ACPR=175).
    
    Might be related to https://sourceforge.net/p/openocd/tickets/263/
    
    Change-Id: Ib4d6df6e34685a9be4c2995cb500b2411c76e39b
    Signed-off-by: Adrian Negreanu <[email protected]>

diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c
index 91ecf56..d44e3c1 100644
--- a/src/jtag/drivers/jlink.c
+++ b/src/jtag/drivers/jlink.c
@@ -1272,7 +1272,7 @@ static bool calculate_swo_prescaler(unsigned int 
traceclkin_freq,
        unsigned int presc;
        double deviation;
 
-       presc = ((1.0 - SWO_MAX_FREQ_DEV) * traceclkin_freq) / trace_freq + 1;
+       presc = traceclkin_freq/trace_freq;
 
        if (presc > TPIU_ACPR_MAX_SWOSCALER)
                return false;

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to