Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

STM32F103C8T6 Bit toggling in task doesn't work?

Posted by nikola1010 on August 24, 2015

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<--------

/* Standard includes. */

include

/* 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
/* 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 prvCheckTask( void *pvParameters ) {

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);

}

} /-----------------------------------------------------------/

static void prvSetupHardware( void ) { /* RCC system reset(for debug purpose). */ RCC_DeInit ();

/* 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 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. */

( void ) pxTask;
( void ) pcTaskName;

for( ;; );

} /-----------------------------------------------------------/

void assert_failed( unsigned char *pucFile, unsigned long ulLine ) { ( void ) pucFile; ( void ) ulLine;

for( ;; );

}


STM32F103C8T6 Bit toggling in task doesn't work?

Posted by nikola1010 on August 25, 2015

Not one hint ? :(


STM32F103C8T6 Bit toggling in task doesn't work?

Posted by rtel on August 26, 2015

You only appear to be creating one task, which is implemented by prvMyTask(), but you don't show the code for that task.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner