¿Por qué mi programa no se ejecuta (funciona)?

2

He comprado esta placa para trabajar con microcontroladores de la serie Cortex-M0. su MCU es STM32F030F4P6. este es el tablero:

y su esquema:

UtilicéSTM32CubeMXparaconfigurarlaMCUyluegouséMDK-5(keiluvision)paraescribirunprogramaBlink.Elprogramaeseste:

/*********************************************************************************FileName:main.c*Date:23/06/201417:53:47*Description:Mainprogrambody********************************************************************************COPYRIGHT(c)2014STMicroelectronics**Redistributionanduseinsourceandbinaryforms,withorwithoutmodification,*arepermittedprovidedthatthefollowingconditionsaremet:*1.Redistributionsofsourcecodemustretaintheabovecopyrightnotice,*thislistofconditionsandthefollowingdisclaimer.*2.Redistributionsinbinaryformmustreproducetheabovecopyrightnotice,*thislistofconditionsandthefollowingdisclaimerinthedocumentation*and/orothermaterialsprovidedwiththedistribution.*3.NeitherthenameofSTMicroelectronicsnorthenamesofitscontributors*maybeusedtoendorseorpromoteproductsderivedfromthissoftware*withoutspecificpriorwrittenpermission.**THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS"AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx_hal.h"

/* Private variables ---------------------------------------------------------*/

/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);

void  Delay (uint32_t nCount)
{
  for(; nCount != 0; nCount--);
}

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* System interrupt init*/
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

  /* Initialize all configured peripherals */
  MX_GPIO_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* USER CODE BEGIN 3 */
  /* Infinite loop */
  while (1)
  {
        HAL_GPIO_TogglePin(GPIOA , GPIO_PIN_0);
        Delay(0xfffff);
        Delay(0xfffff);
        Delay(0x5ffff); 
        HAL_GPIO_TogglePin(GPIOA , GPIO_PIN_0);
        Delay(0xfffff);
        Delay(0xfffff);
        Delay(0x5ffff); 

  }
  /* USER CODE END 3 */

}

/** System Clock Configuration
*/
void SystemClock_Config(void)
{

  RCC_ClkInitTypeDef RCC_ClkInitStruct;
  RCC_OscInitTypeDef RCC_OscInitStruct;

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = 16;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12;
  RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
  HAL_RCC_OscConfig(&RCC_OscInitStruct);

  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);

  __SYSCFG_CLK_ENABLE();

}

/** Configure pins as 
        * Analog 
        * Input 
        * Output
        * EVENT_OUT
        * EXTI
*/
void MX_GPIO_Init(void)
{

  GPIO_InitTypeDef GPIO_InitStruct;

  /* GPIO Ports Clock Enable */
  __GPIOF_CLK_ENABLE();
  __GPIOA_CLK_ENABLE();

  /*Configure GPIO pin : PA1 */
  GPIO_InitStruct.Pin = GPIO_PIN_1;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

#ifdef USE_FULL_ASSERT

/**
   * @brief Reports the name of the source file and the source line number
   * where the assert_param error has occurred.
   * @param file: pointer to the source file name
   * @param line: assert_param error line source number
   * @retval None
   */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */

}

#endif

/**
  * @}
  */ 

/**
  * @}
*/ 

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

Lo compilé y el keil hizo el archivo HEX muy bien. Tengo que conectar la placa a J-Link como esta imagen:

Estábien,estábien,loconectécorrectamente.mira:

Descargoelprograma.Hastaahora,todoestábien,¡peronoestrabajo!

En su opinión, ¿en qué me equivoco?

    
pregunta Roh

2 respuestas

0

+1 a waltx y gracias especiales a él y @BrianDrummond. Encontré el problema. Agregue a la respuesta de ambos chicos, el gran problema fue la función 'retraso ()'. Hizo un gran retraso para Blink. Reemplacé un 'Retardo (0x29020c0)' después de la función de alternar y ahora funciona. Gracias de nuevo, chicos.

    
respondido por el Roh
2

En la función "void MX_GPIO_Init (void)" el pin 1 se está inicializando.

En el bucle, el pin 0 se está alternando.

    
respondido por el waltx

Lea otras preguntas en las etiquetas