system
(system)
March 21, 2006, 1:00pm
1
nobody wrote on Tuesday, March 21, 2006 :
Salam,
in port.c
ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ;
That’s wrong cause the clock of the peripherals (include Timer0) is NOT CPU Clock (CCLK) but it’s PCLK.
and
PCLK = CCLK / VBP Divider
At reset for LPC2129 VBP Divider = 4
So The above line must be
ulCompareMatch = (configCPU_CLOCK_HZ /4 ) / configTICK_RATE_HZ;
I found this bug when i was trying to blink a led every second using vTaskDelayUntil
Here is my working code.
static void vTaskCode(void *pvParameters)
{
portTickType xLastWakeTime;
const portTickType xFrequency = 1000;
xLastWakeTime = xTaskGetTickCount();
for (; {
Led_Toggle();
vTaskDelayUntil( &xLastWakeTime, xFrequency );
}
}
Bye
Eng. Amr Ahmed
EGYPT
system
(system)
March 21, 2006, 1:03pm
2
nobody wrote on Tuesday, March 21, 2006 :
I forgot to mention that configTICK_RATE_HZ must be configure to 1000 in freeRTOSconfig.h to use the above task to blink the led every 1 SEC
Enjoy
Amr Ahmed
EGYPT
system
(system)
March 21, 2006, 1:06pm
3
nobody wrote on Tuesday, March 21, 2006 :
I think, as downloaded, the line should actually be:
ulCompareMatch = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1;
cpu clock being defined to the correect value for the equation.
You change the value or use different hardware?
system
(system)
March 21, 2006, 1:24pm
4
nobody wrote on Tuesday, March 21, 2006 :
AS DOWNLOADED THE LINE IS
/* Calculate the match value required for our wanted tick rate. */
ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ;
THAT IS NOT RIGHTTTTTTTTTTTT
system
(system)
March 21, 2006, 1:36pm
5
nobody wrote on Tuesday, March 21, 2006 :
AS DOWNLOADED
ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ;
This is not right !!!
I use Olimex board (LPC2129)
So configCPU_CLOCK_HZ = 14745600 (crystal value)
I didn’t use the PLL.
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 14745600 )
BYE
system
(system)
March 21, 2006, 1:36pm
6
nobody wrote on Tuesday, March 21, 2006 :
It is right if you are using the same software and hardware as the demo with no modifications at all. I know because I can time the LED’s flashing and they are exactly correct.
I think you are making an assumption as to what configCPU_CLOCK_HZ means. This should be set to the frequency as used by the timer which may but probably will not be the same as some other clocks on the system.
system
(system)
March 21, 2006, 1:39pm
7
nobody wrote on Tuesday, March 21, 2006 :
That’s right man.
configCPU_CLOCK_HZ must be the clock of the Timer.
So configCPU_CLOCK_HZ must be
configCPU_CLOCK_HZ = configCPU_CLOCK_HZ / VBP Divider
Please look to the datasheet
Bye
AmR Ahmed
EGYPT