hobit222 wrote on Thursday, July 17, 2014:
Hello,
We are running the (unsupported) port of FreeRTOS to the Raspberry Pi (latest version etc.) I’ve inherited a few changes, but as far as I know there are no changes from the base build for the Pi.
I’ve got a task that does a for-loop delay, then turns on an LED, does the delay again and turns it off. (code below)
When running the code as a task, I’m seeing the period of the output be as low as 885us and as high as 910us. When I run the task as the main (so just move the task code into main and don’t run the scheduler) and disable interrupts I get 884.4us to 885.4us (over 40k samples).
Additional data: When removing the for loop but running as a task, we see 4us period with the rare (every 1000 samples?) 10us period. Feels like there is a 6uS delay popping in there.
Am I seeing the kernel/scheduler overhead here? I’m assuming the Pi is running at a high frequency, but if it’s slower (24MHz?) that might be be reasonable (170 cycles?) though it seems high.
If it is running at a low frequency, then is there a clean way to speed it up?
Thanks.
Mark
void task1(void *pParam) {
volatile int i = 0;
while(1) {
SetGpio(16, ON_N);
SetGpio(17, ON_N);
for(i=0;i<2000;i++);
SetGpio(16, OFF_N);
SetGpio(17, OFF_N);
for(i=0;i<2000;i++);
}
}
void main(void) {
DisableInterrupts();
InitInterruptController();
SetGpioDirection(16, GPIO_OUT); // green LED
SetGpioDirection(17, GPIO_OUT); // accessable GPIO pin
xTaskCreate(task1, "LED_0", 128, NULL, 0, NULL);
vTaskStartScheduler();