I actually get ~30ms when using 1-10 delay ticks. If I use greater than 10, the actual blocking delay is (ticks x 3).
my hardware setup func
~~~~~~~
static void prvSetupHardware( void )
{
/* Start with the clocks in their expected state. */
RCC_DeInit();
/* Enable HSE (high speed external clock). */
RCCHSEConfig( RCCHSE_ON );
/* Wait till HSE is ready. */
while( RCCGetFlagStatus( RCCFLAG_HSERDY ) == RESET )
{
}
/* 2 wait states required on the flash. */
*( ( unsigned long * ) 0x40022000 ) = 0x02;
/* HCLK = SYSCLK */
RCCHCLKConfig( RCCSYSCLK_Div1 );
/* PCLK2 = HCLK */
RCCPCLK2Config( RCCHCLK_Div1 );
/* PCLK1 = HCLK/2 */
RCCPCLK1Config( RCCHCLK_Div2 );
/* PLLCLK = (25MHz / 2 ) * 5 = 62.5 MHz. */
RCCPLLConfig( RCCPLLSourceHSIDiv2, RCCPLLMul5 );
/* Enable PLL. */
RCC_PLLCmd( ENABLE );
/* Wait till PLL is ready. */
while(RCCGetFlagStatus(RCCFLAG_PLLRDY) == RESET)
{
}
/* Select PLL as system clock source. */
RCCSYSCLKConfig( RCCSYSCLKSource_PLLCLK );
/* Wait till PLL is used as system clock source. */
while( RCC_GetSYSCLKSource() != 0x08 )
{
}
/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */
RCCAPB2PeriphClockCmd( RCCAPB2PeriphGPIOA | RCCAPB2PeriphGPIOB |RCCAPB2PeriphGPIOC
| RCCAPB2PeriphGPIOD | RCCAPB2PeriphGPIOE | RCCAPB2Periph_AFIO, ENABLE );
/* Set the Vector Table base address at 0x08000000 */
NVICSetVectorTable( NVICVectTab_FLASH, 0x0);
NVICPriorityGroupConfig( NVICPriorityGroup_4 );
/* Configure HCLK clock as SysTick clock source. */
SysTickCLKSourceConfig( SysTickCLKSource_HCLK );
}
~~~~~~~
freertos config
~~~~~~~
ifndef FREERTOSCONFIGH
define FREERTOSCONFIGH
define configUSE_PREEMPTION 1
define configUSEIDLEHOOK 0
define configUSETICKHOOK 0
define configCPUCLOCKHZ ( ( unsigned long ) 62500000 )
define configTICKRATEHZ ( ( TickType_t ) 1000 )
define configMAX_PRIORITIES ( 6 )
define configMINIMALSTACKSIZE ( ( unsigned short ) 128 )
define configTOTALHEAPSIZE ( ( size_t ) ( 30 * 1024 ) )
define configMAXTASKNAME_LEN ( 16 )
define configUSE16BIT_TICKS 0
define configIDLESHOULDYIELD 1
/* Co-routine definitions. */
define configUSECOROUTINES 0
define configMAXCOROUTINE_PRIORITIES ( 2 )
define configUSE_MUTEXES 1
define configUSECOUNTINGSEMAPHORES 0
define configUSEALTERNATIVEAPI 0
define configCHECKFORSTACK_OVERFLOW 2
define configUSERECURSIVEMUTEXES 1
define configQUEUEREGISTRYSIZE 0
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
define INCLUDE_vTaskPrioritySet 1
define INCLUDE_uxTaskPriorityGet 1
define INCLUDE_vTaskDelete 1
define INCLUDE_vTaskCleanUpResources 0
define INCLUDE_vTaskSuspend 1
define INCLUDE_vTaskDelayUntil 1
define INCLUDE_vTaskDelay 1
/* This demo makes use of one or more example stats formatting functions. These
format the raw data provided by the uxTaskGetSystemState() function in to human
readable ASCII form. See the notes in the implementation of vTaskList() within
FreeRTOS/Source/tasks.c for limitations. */
define configUSESTATSFORMATTING_FUNCTIONS 1
define configUSETRACEFACILITY 1
define configGENERATERUNTIME_STATS 0
/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255
(lowest) to 0 (1?) (highest). */
define configKERNELINTERRUPTPRIORITY 255
/* !!!! configMAXSYSCALLINTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
define configMAXSYSCALLINTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */
/* This is the value being used as per the ST library which permits 16
priority values, 0 to 15. This must correspond to the
configKERNELINTERRUPTPRIORITY setting. Here 15 corresponds to the lowest
NVIC value of 255. */
define configLIBRARYKERNELINTERRUPT_PRIORITY 15
define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
/-----------------------------------------------------------
* Macros required to setup the timer for the run time stats.
*-----------------------------------------------------------/
/* The run time stats time base just uses the existing high frequency timer
test clock. All these macros do is clear and return the high frequency
interrupt count respectively. */
extern unsigned long ulRunTimeStatsClock;
define portCONFIGURETIMERFORRUNTIME_STATS() ulRunTimeStatsClock = 0
define portGETRUNTIMECOUNTERVALUE() ulRunTimeStatsClock
//NEED THESE!!
define vPortSVCHandler SVC_Handler
define xPortPendSVHandler PendSV_Handler
define xPortSysTickHandler SysTick_Handler
endif /* FREERTOSCONFIGH */
~~~~~~~
toggle task
~~~~~~~
static void prvTOGGLETask( void *pvParameters )
{
char bit = 0;
portTickType xLastWakeTime;
xLastWakeTime = xTaskGetTickCount();
/* Block for 10ms. */
const TickTypet xDelay = 10 / portTICKPERIOD_MS;
for(;;)
{
if(bit)
GPIOC->BSRR = 1 << 6;
else
GPIOC->BRR = 1 << 6;
bit = !bit;
vTaskDelayUntil( &xLastWakeTime, xDelay);
}
}
~~~~~~~
Thank you very much for your responses!
I found the problem.
Apologies for the lack of relevance to FreeRTOS.
In the demo program, the prvSetupHardware() function sets the clock as so:
~~~~~~
/* PLLCLK = (25MHz / 2 ) * 5 = 62.5 MHz. */
RCCPLLConfig( RCCPLLSourceHSIDiv2, RCCPLLMul5 );
~~~~~~
But in the most recent stm32f10xrcc.h, RCCPLLSourceHSEDiv2 is not defined for STM32F10X_CL, which is this chip.
~~~~~~
/** @defgroup PLLentryclock_source
* @{
*/
define RCCPLLSourceHSIDiv2 ((uint32t)0x00000000)
if !defined (STM32F10XLDVL) && !defined (STM32F10XMDVL) && !defined (STM32F10XHDVL) && !defined (STM32F10X_CL)
#define RCCPLLSourceHSEDiv1 ((uint32t)0x00010000)
#define RCCPLLSourceHSEDiv2 ((uint32t)0x00030000)
#define ISRCCPLLSOURCE(SOURCE) (((SOURCE) == RCCPLLSourceHSIDiv2) ||
((SOURCE) == RCCPLLSourceHSEDiv1) ||
((SOURCE) == RCCPLLSourceHSEDiv2))
else
#define RCCPLLSourcePREDIV1 ((uint32t)0x00010000)
#define ISRCCPLLSOURCE(SOURCE) (((SOURCE) == RCCPLLSourceHSIDiv2) ||
((SOURCE) == RCCPLLSource_PREDIV1))
endif /* STM32F10X_CL */
~~~~~~
I used the value ((uint32_t)0x00030000), and I am now getting ~10ms.