CTRLSTAT = 0xffffffff

Sir,

I am working on Cortex-M4 over serial wire debug protocol, i am able to read IDCODE(0x2ba01477) which is correct as per arm cortex m4 technical reference manual, and i am writing 0x50000000 to CTRLSTAT register to enable CSYSPWRUPREQ and CDBGPWRREQ which is also success without any ACK error,but the thing is when i am trying to read the CTRLSTAT register i got 0xffffffff . I don't understand what might be the problem,Please suggest me what would be the problem??

Thanks & Regards

Parents
  • Unfortunately I do not have a specific answer, but I believe that I may be able to hint you towards solving the problem.

    First rule: Always assume that your debug-code is not 100% correct. It's really annoying to struggle with a problem for days, and finally discover that something was wrong with the debug-code - I've done that countless times.

    For STMicroelectronics's own documentation on the subject, please see RM0090, section 38.3.1.

    First of all, we'll need to make sure your connection is OK.

    When I connect a JTAG-Lock-pick Tiny 2 to my targets, I use the standard JTAG pull-up and pull-down resistors:

    • TCLK/SWDCLK: 10K pull-down
    • TMS/SWDIO: 10K pull-up
    • TDO/SWO: 10K pull-up

    ... Next, do you switch from output to input, when you're reading the CTRL/STAT register ?

    ... Also... The address; are you encoding it correctly, so (only) bits 3 and 4 in the first byte you send are modified ?

    ... If you have a logic-analyzer, it might be a good idea to connect it, in order to monitor the values sent and received on the pins.

    ... If you have a logic-analyzer, try monitoring the data that OpenOCD transfers to the target when it starts up, then compare to your own data.

    I know this sounds ridiculous, but it is a very good idea to write some low-level debug code, which shows you exactly what is going on.

    It will probably be a good idea to make a temporary modification to your transmit routine, the one routine, that sends a single bit:

    It should output either a 0 or a 1, depending on the data it sends.

    Then after each stream of bits, you send output a space.

    Finally, at the end of each transfer, you output a newline character.

    Transmit all the data from above to your debug-terminal via a UART interface, if you have a terminal connected to the board.

    Example of making the code fast (do not use printf in your bit-transmitter code):

    1: Create a static buffer and a static pointer variable outside your transmission function:

    static char sDebugBuffer[128];

    static char *pDebugBufffer = sDebugBuffer;

    2: Before starting each transmission, do the following:

    pDebugBuffer = sDebugBuffer;

    3: Each time you transmit a bit, do the following:

    *pDebugBuffer++ = '0' + bitValue;

    4: Each time you're done transmitting a sequence of bits (for instance 8 bits for a byte, or 3 bits for the response code, or 33 bits for the WDATA, do the following:

    *pDebugBuffer++ = 0x20;

    5: Each time a transfer ends, do the following:

    *pDebugBuffer++ = 0x0a;

    *pDebugBuffer = 0x00;

    pDebugBuffer = sDebugBuffer;

    /* and write the contents of the debug-buffer to your UART; maybe you're using UART_send, maybe write, maybe printf, let's assume printf in this case: */

    printf("%s", sDebugBuffer);

    This enables you to verify that your transmission is correct length, and it will also enable you to see exactly what bit-values are sent, so you can verify they're what you expect them to be.

    For the response, you can of course also implement a similar mechanism.

Reply
  • Unfortunately I do not have a specific answer, but I believe that I may be able to hint you towards solving the problem.

    First rule: Always assume that your debug-code is not 100% correct. It's really annoying to struggle with a problem for days, and finally discover that something was wrong with the debug-code - I've done that countless times.

    For STMicroelectronics's own documentation on the subject, please see RM0090, section 38.3.1.

    First of all, we'll need to make sure your connection is OK.

    When I connect a JTAG-Lock-pick Tiny 2 to my targets, I use the standard JTAG pull-up and pull-down resistors:

    • TCLK/SWDCLK: 10K pull-down
    • TMS/SWDIO: 10K pull-up
    • TDO/SWO: 10K pull-up

    ... Next, do you switch from output to input, when you're reading the CTRL/STAT register ?

    ... Also... The address; are you encoding it correctly, so (only) bits 3 and 4 in the first byte you send are modified ?

    ... If you have a logic-analyzer, it might be a good idea to connect it, in order to monitor the values sent and received on the pins.

    ... If you have a logic-analyzer, try monitoring the data that OpenOCD transfers to the target when it starts up, then compare to your own data.

    I know this sounds ridiculous, but it is a very good idea to write some low-level debug code, which shows you exactly what is going on.

    It will probably be a good idea to make a temporary modification to your transmit routine, the one routine, that sends a single bit:

    It should output either a 0 or a 1, depending on the data it sends.

    Then after each stream of bits, you send output a space.

    Finally, at the end of each transfer, you output a newline character.

    Transmit all the data from above to your debug-terminal via a UART interface, if you have a terminal connected to the board.

    Example of making the code fast (do not use printf in your bit-transmitter code):

    1: Create a static buffer and a static pointer variable outside your transmission function:

    static char sDebugBuffer[128];

    static char *pDebugBufffer = sDebugBuffer;

    2: Before starting each transmission, do the following:

    pDebugBuffer = sDebugBuffer;

    3: Each time you transmit a bit, do the following:

    *pDebugBuffer++ = '0' + bitValue;

    4: Each time you're done transmitting a sequence of bits (for instance 8 bits for a byte, or 3 bits for the response code, or 33 bits for the WDATA, do the following:

    *pDebugBuffer++ = 0x20;

    5: Each time a transfer ends, do the following:

    *pDebugBuffer++ = 0x0a;

    *pDebugBuffer = 0x00;

    pDebugBuffer = sDebugBuffer;

    /* and write the contents of the debug-buffer to your UART; maybe you're using UART_send, maybe write, maybe printf, let's assume printf in this case: */

    printf("%s", sDebugBuffer);

    This enables you to verify that your transmission is correct length, and it will also enable you to see exactly what bit-values are sent, so you can verify they're what you expect them to be.

    For the response, you can of course also implement a similar mechanism.

Children