Skip to content

Commit

Permalink
Use 1kHz timestamp clock for simplicity
Browse files Browse the repository at this point in the history
The pin stabilization timer doesn't really need high resolution and
computing it out to 1us is slow, so use the 1ms tick timestamp directly.
  • Loading branch information
devanlai committed Jan 28, 2023
1 parent 22556ca commit 5e2eb41
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 18 deletions.
7 changes: 2 additions & 5 deletions src/stm32f042/DAP/CMSIS_DAP_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@
* TIMESTAMP SUPPORT
*/

// Get current timestamp value, in micro-seconds:
// Get current timestamp value, in milliseconds:
// Use SYSTICK value and timer ticks, assume 1ms counter.
static __inline uint32_t TIMESTAMP_GET (void) {
uint32_t reload = STK_RVR;
uint32_t current = STK_CVR;
uint32_t tick = get_ticks();
return tick * 1000U + (reload - current) / (CPU_CLOCK / TIMESTAMP_CLOCK);
return get_ticks();
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f042/brain3.3/DAP/CMSIS_DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ This information includes:
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.

/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
#define TIMESTAMP_CLOCK 48000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
#define TIMESTAMP_CLOCK 1000U ///< Timestamp clock in Hz (0 = timestamps not supported).

/// Debug Unit is connected to fixed Target Device.
/// The Debug Unit may be part of an evaluation board and always connected to a fixed
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f042/dap42/DAP/CMSIS_DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ This information includes:
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.

/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
#define TIMESTAMP_CLOCK 48000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
#define TIMESTAMP_CLOCK 1000U ///< Timestamp clock in Hz (0 = timestamps not supported).

/// Debug Unit is connected to fixed Target Device.
/// The Debug Unit may be part of an evaluation board and always connected to a fixed
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f042/dap42dc/DAP/CMSIS_DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ This information includes:
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.

/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
#define TIMESTAMP_CLOCK 48000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
#define TIMESTAMP_CLOCK 1000U ///< Timestamp clock in Hz (0 = timestamps not supported).

/// Debug Unit is connected to fixed Target Device.
/// The Debug Unit may be part of an evaluation board and always connected to a fixed
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f042/dap42k6u/DAP/CMSIS_DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ This information includes:
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.

/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
#define TIMESTAMP_CLOCK 48000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
#define TIMESTAMP_CLOCK 1000U ///< Timestamp clock in Hz (0 = timestamps not supported).

/// Debug Unit is connected to fixed Target Device.
/// The Debug Unit may be part of an evaluation board and always connected to a fixed
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f042/kitchen42/DAP/CMSIS_DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ This information includes:
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.

/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
#define TIMESTAMP_CLOCK 48000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
#define TIMESTAMP_CLOCK 1000U ///< Timestamp clock in Hz (0 = timestamps not supported).

/// Debug Unit is connected to fixed Target Device.
/// The Debug Unit may be part of an evaluation board and always connected to a fixed
Expand Down
7 changes: 2 additions & 5 deletions src/stm32f103/DAP/CMSIS_DAP_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@
* TIMESTAMP SUPPORT
*/

// Get current timestamp value, in micro-seconds:
// Get current timestamp value, in milliseconds:
// Use SYSTICK value and timer ticks, assume 1ms counter.
static __inline uint32_t TIMESTAMP_GET (void) {
uint32_t reload = STK_RVR;
uint32_t current = STK_CVR;
uint32_t tick = get_ticks();
return tick * 1000U + (reload - current) / (CPU_CLOCK / TIMESTAMP_CLOCK);
return get_ticks();
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f103/bluepill/DAP/CMSIS_DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ This information includes:
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.

/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
#define TIMESTAMP_CLOCK 72000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
#define TIMESTAMP_CLOCK 1000U ///< Timestamp clock in Hz (0 = timestamps not supported).

/// Debug Unit is connected to fixed Target Device.
/// The Debug Unit may be part of an evaluation board and always connected to a fixed
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f103/stlinkv2-1/DAP/CMSIS_DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ This information includes:
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.

/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
#define TIMESTAMP_CLOCK 72000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
#define TIMESTAMP_CLOCK 1000U ///< Timestamp clock in Hz (0 = timestamps not supported).

/// Debug Unit is connected to fixed Target Device.
/// The Debug Unit may be part of an evaluation board and always connected to a fixed
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f103/stlinkv2-dongle/DAP/CMSIS_DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ This information includes:
#define SWO_STREAM 0 ///< SWO Streaming Trace: 1 = available, 0 = not available.

/// Clock frequency of the Test Domain Timer. Timer value is returned with \ref TIMESTAMP_GET.
#define TIMESTAMP_CLOCK 72000000U ///< Timestamp clock in Hz (0 = timestamps not supported).
#define TIMESTAMP_CLOCK 1000U ///< Timestamp clock in Hz (0 = timestamps not supported).

/// Debug Unit is connected to fixed Target Device.
/// The Debug Unit may be part of an evaluation board and always connected to a fixed
Expand Down

0 comments on commit 5e2eb41

Please sign in to comment.