Hi
I'm testing RTX on TM4C129KCPDT,using CMSIS-RTOS Blinky sample soruce.
I downloaded sample below.(CMSIS-RTOS Blinky sample)
https://www.keil.com/dd/chip/7092.htm
I set osDelay to 80ms, but it's actually 95ms and there is a 12ms delay.
Is it due to processing delay?
[Confirming method]
I confirmed by displaying on clock signal and phase A signal on uvision's Logic Analyzer(analysis window).
/*---------------------------------------------------------------------------- * RL-ARM - RTX *---------------------------------------------------------------------------- * Name: BLinky.c * Purpose: RTX example program *---------------------------------------------------------------------------- * This code is part of the RealView Run-Time Library. * Copyright (c) 2004-2014 KEIL - An ARM Company. All rights reserved. *---------------------------------------------------------------------------*/ #include "cmsis_os.h" #include "TM4C129.h" // Device header #include "LED.h" osThreadId tid_phaseA; /* Thread id of thread: phase_a */ osThreadId tid_phaseB; /* Thread id of thread: phase_b */ osThreadId tid_phaseC; /* Thread id of thread: phase_c */ osThreadId tid_phaseD; /* Thread id of thread: phase_d */ osThreadId tid_clock; /* Thread id of thread: clock */ #define LED_A 0 #define LED_B 1 #define LED_C 2 #define LED_D 3 #define LED_CLK 7 unsigned char phaseA_sig; unsigned char phaseB_sig; unsigned char phaseC_sig; unsigned char phaseD_sig; unsigned char clk_sig; /*---------------------------------------------------------------------------- * Switch LED on *---------------------------------------------------------------------------*/ void Switch_On (unsigned char led) { if (led == LED_CLK) LED_On (0); } /*---------------------------------------------------------------------------- * Switch LED off *---------------------------------------------------------------------------*/ void Switch_Off (unsigned char led) { if (led == LED_CLK) LED_Off (0); } /*---------------------------------------------------------------------------- * Function 'signal_func' called from multiple threads *---------------------------------------------------------------------------*/ void signal_func (osThreadId tid) { osSignalSet(tid_clock, 0x0001); /* set signal to clock thread */ osDelay(500); /* delay 500ms */ osSignalSet(tid_clock, 0x0001); /* set signal to clock thread */ osDelay(500); /* delay 500ms */ osSignalSet(tid, 0x0001); /* set signal to thread 'thread' */ osDelay(500); /* delay 500ms */ } /*---------------------------------------------------------------------------- * Thread 1 'phaseA': Phase A output *---------------------------------------------------------------------------*/ void phaseA (void const *argument) { for (;;) { osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0001 */ phaseA_sig = 1; Switch_On (LED_A); signal_func(tid_phaseB); /* call common signal function */ phaseA_sig = 0; Switch_Off(LED_A); } } /*---------------------------------------------------------------------------- * Thread 2 'phaseB': Phase B output *---------------------------------------------------------------------------*/ void phaseB (void const *argument) { for (;;) { osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0001 */ Switch_On (LED_B); phaseB_sig = 1; signal_func(tid_phaseC); /* call common signal function */ Switch_Off(LED_B); phaseB_sig = 0; } } /*---------------------------------------------------------------------------- * Thread 3 'phaseC': Phase C output *---------------------------------------------------------------------------*/ void phaseC (void const *argument) { for (;;) { osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0001 */ Switch_On (LED_C); phaseC_sig = 1; signal_func(tid_phaseD); /* call common signal function */ Switch_Off(LED_C); phaseC_sig = 0; } } /*---------------------------------------------------------------------------- * Thread 4 'phaseD': Phase D output *---------------------------------------------------------------------------*/ void phaseD (void const *argument) { for (;;) { osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0001 */ Switch_On (LED_D); phaseD_sig = 1; signal_func(tid_phaseA); /* call common signal function */ Switch_Off(LED_D); phaseD_sig = 0; } } /*---------------------------------------------------------------------------- * Thread 5 'clock': Signal Clock *---------------------------------------------------------------------------*/ void clock (void const *argument) { for (;;) { osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0100 */ clk_sig = 1; Switch_On (LED_CLK); osDelay(80); /* delay 80ms */ clk_sig = 0; Switch_Off(LED_CLK); } } osThreadDef(phaseA, osPriorityNormal, 1, 0); osThreadDef(phaseB, osPriorityNormal, 1, 0); osThreadDef(phaseC, osPriorityNormal, 1, 0); osThreadDef(phaseD, osPriorityNormal, 1, 0); osThreadDef(clock, osPriorityNormal, 1, 0); /*---------------------------------------------------------------------------- * Main: Initialize and start RTX Kernel *---------------------------------------------------------------------------*/ int main (void) { SystemCoreClockUpdate(); LED_Initialize(); /* Initialize the LEDs */ tid_phaseA = osThreadCreate(osThread(phaseA), NULL); tid_phaseB = osThreadCreate(osThread(phaseB), NULL); tid_phaseC = osThreadCreate(osThread(phaseC), NULL); tid_phaseD = osThreadCreate(osThread(phaseD), NULL); tid_clock = osThreadCreate(osThread(clock), NULL); osSignalSet(tid_phaseA, 0x0001); /* set signal to phaseA thread */ osDelay(osWaitForever); while(1); }
The logic analyzer window and source code are shown below.I would appreciate it if you would answer my question.
Thank you for your answer.
I don't know "OS TICK" setting.
Would you please answer following question.
I set the "RTX Timer tick interval value" to 1ms, so I thought OS_TICK was 1ms.but When I checked the cycle of sys tick, it was 1.6ms.
Why is the sys tick period not set to 1ms?
I set "RTX Timer tick interval value"= 1000[us],and "RTOS Kernel Timer input clock frequency" = 16MHz..(The OSC input of TM4C129 is 16MHz)Configuration Wizard
sys tick cycle = 1.6ms
The value of SysClk should be used as for the Kernel timer input frequency, not the OSC.
The value of the SysClk is configured by "YOU" (i.e. you are 100% responsible for this being correct and what you want, even though it is done in the SystemCoreClockUpdate() function. If it does not provide the SysClk you want, you need to adjust the code).
All vendors do clocks differently and often within the same vendor chips have different ways of configuring and using the clocks.
You most likely want a SysClk of 120MHz for this chip. You should look through the SystemCoreClockUpdate() code, make sure it knows what the proper external OSC frequency is, and make sure it is using the external OSC (that is if that is what you want)