Hi - My blinking light was running at half speed, and I assumed I’d set up the microprocessor clock wrong. After a couple hours checking all the clock configuration options, I found a small 2x error in the port.c timer setup… Here’s the fix:
// DRN: Timer clock input is system clock >>> DIVIDED BY 2 <<< // DRN: See DS39704A-page 14-6: bit 1 TCS: // DRN: Timerx Clock Source Select bit: 0 = Internal clock (FOSC/2) // DRN: line below fixed to reflect this... const unsigned long ulCompareMatch = ( ( (configCPU_CLOCK_HZ/2) / portTIMER_PRESCALE ) / configTICK_RATE_HZ ) - 1; // DRN // DRN: Was: const unsigned long ulCompareMatch = ( ( configCPU_CLOCK_HZ / portTIMER_PRESCALE ) / configTICK_RATE_HZ ) - 1;
Note 1: the CPU clock on PIC24F is typically 32MHz, but the instruction clock is always 1/2 this value. The timer input takes the CPU clock/2.
Note 2: The CPU clock can be reduced in “Doze Mode” power-saving - this is not provided for in FreeRTOS.
Hope this is helpful !
Best Regards, Dave