Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

LedToggle

Posted by Do on May 30, 2013
Hi,
Am trying to flash a led of an STM32-P107, i created a freertos code, i compiled the project without having errors but there is no result on the card, This is my code :


/ Standard includes. /
include
include

/ Scheduler includes. /
include \"FreeRTOS.h\"
include \"task.h\"
include \"queue.h\"
include \"semphr.h\"
include \"leds.h\"
include \"button.h\"
include \"stm32f10x_conf.h\"
include \"stm32_eval.h\"
include \"partest.h\"

/ Task priorities. /
define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )

/ Task priorities. /
define TASKPRIORITY1 (tskIDLE_PRIORITY + 1)
define TASKPRIORITY2 (tskIDLE_PRIORITY + 2)
define TASKPRIORITY3 (tskIDLE_PRIORITY + 3)

/ The rate at which the flash task toggles the LED. /
define mainFLASH_DELAY ( ( portTickType ) 25 / portTICK_RATE_MS )

/ The number of nano seconds between each processor clock. /
define mainNS_PER_CLOCK ( ( unsigned portLONG ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) )

/-----------------------------------------------------------/

/
* Configure the clocks, GPIO and other peripherals as required by the demo.
/
static void prvSetupHardware(void);

/
* The LCD is written two by more than one task so is controlled by a
* \'gatekeeper\' task. This is the only task that is actually permitted to
* access the LCD directly. Other tasks wanting to display a message send
* the message to the gatekeeper.
/
extern int sprintf(char out, const char format, ...);

xTaskHandle xTaskLed;
void vTaskFunction( void * pvParameters );
//void vTaskLed( void *pvParameters );

/-----------------------------------------------------------/

int main(void) {

prvSetupHardware();

setbuf(stdout,NULL);
/* Start the scheduler. */
printf(\"########################## MINI PROJET CS530 ################\\n\");
ButtonInit();
LEDsInit();

xTaskCreate(vTaskFunction,\"vTaskFunction\", configMINIMAL_STACK_SIZE+50 , NULL, TASKPRIORITY1,NULL);
// xTaskCreate( vTaskLed, \"vTaskLed\", configMINIMAL_STACK_SIZE+50, NULL, TASKPRIORITY2, &xTaskLed );
GPIO_WriteBit( GPIOC, GPIO_Pin_6,Bit_SET );
vTaskStartScheduler();

/* Will only get here if there was not enough heap space to create the
idle task. */
return 0;

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

static void prvSetupHardware(void) {

USART_InitTypeDef USART_InitStructure;

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

ifdef IAP_VECT_TAB_RELOCATE

NVIC_SetVectorTable(NVIC_VectTab_FLASH_RELOCATED, 0x0);

else

NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );

endif

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

/* Configure HCLK clock as SysTick clock source. */
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

/* Configure UART */
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl= USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

STM_EVAL_COMInit(COM2, &USART_InitStructure);

}

/-----------------------------------------------------------/

void vTaskFunction( void * pvParameters )
{

const portTickType xDelay = 500 / portTICK_RATE_MS;

for( ;; )
{

LEDToggle(LEDG);
vTaskDelay( xDelay );
}

}

and this the led.c code:
/
* leds.c

* Created on: Nov 8, 2011
* Author: MMM
*/
include \"leds.h\"

void LEDsInit(void)
{
//GPIO structure used to initialize LED port
GPIO_InitTypeDef GPIO_InitStructure;
//Enable clock on APB2 pripheral bus where LEDs are connected
RCC_APB2PeriphClockCmd(LEDPORTCLK, ENABLE);
//select pins to initialize LED
GPIO_InitStructure.GPIO_Pin = LEDG|LEDB;
//select output push-pull mode
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//highest speed available
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(LEDPORT, &GPIO_InitStructure);
}

void LEDToggle(uint32_t LEDn){

{
if(GPIO_ReadOutputDataBit(LEDPORT, LEDn)) //read previous state
{
GPIO_ResetBits(LEDPORT, LEDn); //set to zero
}
else
{
GPIO_SetBits(LEDPORT, LEDn);//set to one
}
}
}

what is wrong please?

RE: LedToggle

Posted by Richard on May 30, 2013
I can't comment on your hardware configuration code as that is very chip specific and outside of the scope of FreeRTOS support. However I do recommend ensuring each part of your application works individually before putting it together.

First, remove all the sprintf() and UART code to cut the project down to a minimum.

Next, if you have not done already, check the LED configuration and toggle code is working without FreeRTOS. Do this by simply calling the initialisation code, and the LED on and LED off code before the scheduler is started. Once you are sure the LED code is working you can start running FreeRTOS - then if the LED is not toggling you know it is not anything to do with the LED interfacing.

When you add in the FreeRTOS code, start with just a single task - the toggle task - again without any printfs or UART code. Put a break point at the beginning of the LED toggling task to ensure the task actually starts executing.

If you have any problems starting the scheduler then report back how far the code gets (step through it to see what happens).

Regards.

RE: LedToggle

Posted by Do on May 31, 2013
I fixed the problem thank you


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists