/* Standard includes. */include <string.h>
/* Scheduler includes. */include “FreeRTOS.h”
include “task.h”
include “queue.h”
include “stm32f10x.h”
include “stm32f10x_rtc.h”
include “stm32f10x_gpio.h”
/* The time between cycles of the ‘check’ task – which depends on whether the check task has detected an error or not. */define mainCHECKDELAYNOERROR ( ( TickTypet ) 5000 / portTICKPERIODMS )
define mainCHECKDELAYERROR ( ( TickTypet ) 500 / portTICKPERIOD_MS )
/* Task priorities. */define mainSEMTESTPRIORITY ( tskIDLE_PRIORITY + 1 )
define mainBLOCKQPRIORITY ( tskIDLE_PRIORITY + 2 )
define mainCHECKTASKPRIORITY ( tskIDLE_PRIORITY + 3 )
define mainFLASHTASKPRIORITY ( tskIDLE_PRIORITY + 2 )
define mainECHOTASKPRIORITY ( tskIDLE_PRIORITY + 1 )
define mainINTEGERTASKPRIORITY ( tskIDLE_PRIORITY )
define mainGENQUEUETASKPRIORITY ( tskIDLEPRIORITY )
/———————————————————–/ /* * Configure the hardware for the demo. */ static void prvSetupHardware( void ); /* The ‘check’ task as described at the top of this file. */ static void prvMyTask( void *pvParameters ); /———————————————————–/ uint8_t gBITSET=0;define mainDELAYLOOPCOUNT ( 0xffffff )
int main( void ) {ifdef DEBUG
debug();endif
} /———————————————————–/ static void prvCheckTask( void *pvParameters ) {/* Set up the clocks and memory interface. */ prvSetupHardware(); /* Create the 'check' task, which is also defined within this file. */ xTaskCreate( prvMyTask, "MyTask", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); /* Start the scheduler. */ vTaskStartScheduler(); /* Will only get here if there was insufficient memory to create the idle task. The idle task is created within vTaskStartScheduler(). */ for( ;; );
} /———————————————————–/ static void prvSetupHardware( void ) { /* RCC system reset(for debug purpose). */ RCC_DeInit ();for( ;; ) { for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ ) // PAUSE {} GPIO_WriteBit(GPIOC , GPIO_Pin_13 , Bit_RESET); for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ ) // PAUSE {} GPIO_WriteBit(GPIOC , GPIO_Pin_13 , Bit_SET); }
} /———————————————————–/ void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) { /* This function will get called if a task overflows its stack. If the parameters are corrupt then inspect pxCurrentTCB to find which was the offending task. *//* Enable HSE. */ RCC_HSEConfig( RCC_HSE_ON ); /* Wait till HSE is ready. */ while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET); /* HCLK = SYSCLK. */ RCC_HCLKConfig( RCC_SYSCLK_Div1 ); /* PCLK2 = HCLK. */ RCC_PCLK2Config( RCC_HCLK_Div1 ); /* PCLK1 = HCLK/2. */ RCC_PCLK1Config( RCC_HCLK_Div2 ); /* ADCCLK = PCLK2/4. */ RCC_ADCCLKConfig( RCC_PCLK2_Div4 ); /* Flash 2 wait state. */ *( volatile unsigned long * )0x40022000 = 0x01; /* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_9 ); /* Enable PLL. */ RCC_PLLCmd( ENABLE ); /* Wait till PLL is ready. */ while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET); /* Select PLL as system clock source. */ RCC_SYSCLKConfig (RCC_SYSCLKSource_PLLCLK); /* Wait till PLL is used as system clock source. */ while (RCC_GetSYSCLKSource() != 0x08); /* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */ RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE ); /* Set the Vector Table base address at 0x08000000. */ NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 ); NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); /* Configure HCLK clock as SysTick clock source. */ SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK ); /* SPI2 Periph clock enable */ RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE ); /**************************************/ GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_WriteBit(GPIOC , GPIO_Pin_13 , Bit_SET);
} /———————————————————–/ void assert_failed( unsigned char *pucFile, unsigned long ulLine ) { ( void ) pucFile; ( void ) ulLine;( void ) pxTask; ( void ) pcTaskName; for( ;; );
}for( ;; );
STM32F103C8T6 Bit toggling in task doesn’t work?
Hi all,
just succedded in compilation of FreeRTOS and wanted to try simple pin toggle.
Small dev board that I got off ebay has led on PC13 (logic low active).
When I put code from task into main it works, but in task itself it does’t.
Could someone provide hint on that? (thank you in advance 🙂
——8<————–8<————–8<————–8<————–8<——–
STM32F103C8T6 Bit toggling in task doesn’t work?
Not one hint ? 🙁
STM32F103C8T6 Bit toggling in task doesn’t work?
You only appear to be creating one task, which is implemented by prvMyTask(), but you don’t show the code for that task.