We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, I wrote FreeRTOS code for STM32f103RB. A simple blinking LED. the program is not giving error while compilation but when i dump code in controller, all led's are glowing. May i know what problem is this. Here is the code below.
#include <stdio.h> /* Library includes. */ #include <stm32f10x_lib.h> //#include "stm32f10x.h" #include "stm32f10x_it.h" #include "stm32f10x_gpio.h"
#include "FreeRTOS.h" #include "task.h" GPIO_InitTypeDef GPIO_InitStructure; static void prvSetupHardware( void );
static void vLEDTask( void *pvParameters ); void Delay(vu32 nCount);
int main (void) { prvSetupHardware();
xTaskCreate( vLEDTask, ( signed portCHAR * ) "LED", 10000, NULL, 1, NULL ); vTaskStartScheduler(); return 0; } void Delay(vu32 nCount) { for(; nCount != 0; nCount--); }
static void vLEDTask(void* pvParameters) { // GPIO_StructInit(GPIO_InitStruct); /* Configure PC.4 as Output push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOB, &GPIO_InitStructure);
while (1) {
/* Turn on led connected to PC.4 pin */ GPIO_SetBits(GPIOB, GPIO_Pin_4); /* Insert delay */ Delay(7200000);
/* Turn off led connected to PC.4 pin */ GPIO_ResetBits(GPIOB, GPIO_Pin_4); /* Insert delay */ Delay(7200000); }
}
/*-----------------------------------------------------------*/
static void prvSetupHardware( void ) { /* Start with the clocks in their expected state. */ RCC_DeInit();
/* Enable HSE (high speed external clock). */ RCC_HSEConfig( RCC_HSE_ON );
/* Wait till HSE is ready. */ while( RCC_GetFlagStatus( RCC_FLAG_HSERDY ) == RESET ) { }
/* 2 wait states required on the flash. */ *( ( unsigned long * ) 0x40022000 ) = 0x02;
/* HCLK = SYSCLK */ RCC_HCLKConfig( RCC_SYSCLK_Div1 );
/* PCLK2 = HCLK */ RCC_PCLK2Config( RCC_HCLK_Div1 );
/* PCLK1 = HCLK/2 */ RCC_PCLK1Config( RCC_HCLK_Div2 );
/* 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 );
/* SPI2 Periph clock enable */ RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, 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 );
// vParTestInitialise();
No code there. Just some random stacking of words. Did you miss the instruction on how to post source code? What did you think was the meaning about the link "Tips for Posting Messages" and the other text directly above the input message box?
You ask what the problem may be. I instead ask: what debugging have you done?