cancel
Showing results for 
Search instead for 
Did you mean: 

I can't get the ouputs to do anything.

Dan in WY
Associate III

I'm using STM32CubeMX and Atollic's TrueStudio to make a simple program that writes to the serial port and turns on and of ports B3 and B4.

I've tried every possible combination in the GPIO section of Pinout & Confiuration of CubeMX and can't read any volts output to those pins. The serial port works fine. I'm using freeRTOS as middleware and have the gpio, uart and freertos in separate source files. Here's the freertos.c file.

#include "task.h"
#include "main.h"
#include "cmsis_os.h"
 
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */     
 
/* USER CODE END Includes */
 
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
#define mainQUEUE_SEND_FREQUENCY_MS			( 2000 / portTICK_PERIOD_MS )
/* USER CODE END PTD */
 
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
 
/* USER CODE END PD */
 
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
 
/* USER CODE END PM */
 
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */
extern UART_HandleTypeDef huart1;
/* USER CODE END Variables */
osThreadId defaultTaskHandle;
osThreadId Task02Handle;
osThreadId Task03Handle;
osMessageQId Queue01Handle;
 
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */
   
/* USER CODE END FunctionPrototypes */
 
void StartDefaultTask(void const * argument);
void StartTask02(void const * argument);
void StartTask03(void const * argument);
 
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
 
/**
  * @brief  FreeRTOS initialization
  * @param  None
  * @retval None
  */
void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */
       
  /* USER CODE END Init */
 
  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */
 
  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */
 
  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */
 
  /* Create the thread(s) */
  /* definition and creation of defaultTask */
  osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
  defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
 
  /* definition and creation of Task02 */
  osThreadDef(Task02, StartTask02, osPriorityIdle, 0, 128);
  Task02Handle = osThreadCreate(osThread(Task02), NULL);
 
  /* definition and creation of Task03 */
  osThreadDef(Task03, StartTask03, osPriorityIdle, 0, 128);
  Task03Handle = osThreadCreate(osThread(Task03), NULL);
 
  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */
 
  /* Create the queue(s) */
  /* definition and creation of Queue01 */
  osMessageQDef(Queue01, 16, uint16_t);
  Queue01Handle = osMessageCreate(osMessageQ(Queue01), NULL);
 
  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */
}
 
/* USER CODE BEGIN Header_StartDefaultTask */
/**
  * @brief  Function implementing the defaultTask thread.
  * @param  argument: Not used 
  * @retval None
  */
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void const * argument)
{
 
  /* USER CODE BEGIN StartDefaultTask */
	UCHAR xchar = 0x22;
	UCHAR buff[100];
	int i;
	for(i = 0;i < 100;i++)
	{
		buff[i] = xchar;
 		if(++xchar > 0x7e)
			xchar = 0x21;
 	}
	i = 0x21;
	/* Infinite loop */
	for(;;)
	{
		HAL_UART_Transmit(&huart1,buff,93,100);
		vTaskDelay(500);
 	}
  /* USER CODE END StartDefaultTask */
}
 
/* USER CODE BEGIN Header_StartTask02 */
/**
* @brief Function implementing the Task02 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartTask02 */
void StartTask02(void const * argument)
{
  /* USER CODE BEGIN StartTask02 */
	unsigned long ulReceivedValue;
  /* Infinite loop */
 
 	static int onoff = 0;
	for(;;)
	{
		xQueueReceive( Queue01Handle, &ulReceivedValue, portMAX_DELAY );
		HAL_GPIO_TogglePin(test5_GPIO_Port, test5_Pin);
		HAL_GPIO_TogglePin(test4_GPIO_Port, test4_Pin);
		
		if(onoff == 0)
		{
			HAL_GPIO_WritePin(LED_PORT_GPIO_Port, LED_PORT_Pin, GPIO_PIN_RESET);
			onoff = 1;
		}else
		{
 			HAL_GPIO_WritePin(LED_PORT_GPIO_Port, LED_PORT_Pin, GPIO_PIN_SET);
		}
	}
 
 
  /* USER CODE END StartTask02 */
}
 
/* USER CODE BEGIN Header_StartTask03 */
/**
* @brief Function implementing the Task03 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartTask03 */
void StartTask03(void const * argument)
{
  /* USER CODE BEGIN StartTask03 */
	const unsigned long ulValueToSend = 500UL;
	TickType_t xNextWakeTime;
  /* Infinite loop */
	for(;;)
	{
		vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );
		xQueueSend( Queue01Handle, &ulValueToSend, 0 );
 
	}
  /* USER CODE END StartTask03 */
}
 
/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */
 
 
/* USER CODE END Application */
 
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

14 REPLIES 14
Dan in WY
Associate III

I've tried an external power supply (3v3) still no luck. This is basically the same code that runs fine on another STM32 (Discovery VL) card.

MikeDB
Lead

What is the actual STM32 IC you are using ? My guess is you have one VDD or VSS pin unconnected.

Dan in WY
Associate III

Hey Mike, thanks for your help. Its a STM32F103C8Tx. I've tried it powering via both the USB port and without the cable connected and using a 3v3 power supply. I haven't tried it with the 5v pin yet.

Oh is this a Blue Pill or similar ?

Dan in WY
Associate III

Yeah, I forgot to mention that: its a Blue Pill.