From fe168fc3d5421f98975bc676330a203be9ae888f Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Tue, 3 Feb 2026 21:22:49 +0100 Subject: [PATCH] corrects time tick settings so that a timer tick happens every 10ms --- port/moonlight/hwtimer.h | 2 +- port/threadx/inc/tx_user.h | 2 +- src/tcp_demo/main.c | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/port/moonlight/hwtimer.h b/port/moonlight/hwtimer.h index 94199da..e146539 100644 --- a/port/moonlight/hwtimer.h +++ b/port/moonlight/hwtimer.h @@ -15,7 +15,7 @@ #include "platform.h" #define TICKNUM_PER_SECOND 32768 -#define TICKNUM_PER_TIMER (TICKNUM_PER_SECOND / 1000) // ~ 1ms timer +#define TICKNUM_PER_TIMER (TICKNUM_PER_SECOND / 100) // ~ 1ms timer static inline int hwtimer_init(void) { uint64_t time = get_aclint_mtime(aclint); diff --git a/port/threadx/inc/tx_user.h b/port/threadx/inc/tx_user.h index d5f3629..cd3d94b 100644 --- a/port/threadx/inc/tx_user.h +++ b/port/threadx/inc/tx_user.h @@ -130,7 +130,7 @@ Note: the actual hardware timer value may need to be changed (usually in tx_initialize_low_level). */ -#define TX_TIMER_TICKS_PER_SECOND (33UL) // for moonlight with 32,7kHz Frequency (divided by 1000) +#define TX_TIMER_TICKS_PER_SECOND (100) // for moonlight with 32,7kHz Frequency (divided by 1000) /* Determine if there is a FileX pointer in the thread control block. diff --git a/src/tcp_demo/main.c b/src/tcp_demo/main.c index f324c4a..b8007d9 100644 --- a/src/tcp_demo/main.c +++ b/src/tcp_demo/main.c @@ -134,7 +134,8 @@ void thread_0_entry(ULONG thread_input) { NX_PARAMETER_NOT_USED(thread_input); - tx_thread_sleep(NX_IP_PERIODIC_RATE); + /* Wait 1 second for the IP thread to finish its initilization. */ + tx_thread_sleep(/* NX_IP_PERIODIC_RATE */ 10); /* set the TCP server addresses. */ server_ipv4_address.nxd_ip_version = NX_IP_VERSION_V4; @@ -234,7 +235,7 @@ void thread_1_entry(ULONG thread_input) { NX_PARAMETER_NOT_USED(thread_input); /* Wait 1 second for the IP thread to finish its initilization. */ - tx_thread_sleep(NX_IP_PERIODIC_RATE); + tx_thread_sleep(/* NX_IP_PERIODIC_RATE */ 10); /* Ensure the IP instance has been initialized. */ status = nx_ip_status_check(&ip_1, NX_IP_INITIALIZE_DONE, &actual_status, NX_IP_PERIODIC_RATE);