cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO toggle example not toggling in BLUENRG 232 MCU. THe program is running and the DAT resistors changing values.

pankajauengg
Associate II

/******************** (C) COPYRIGHT 2015 STMicroelectronics ********************

* File Name     : GPIO/IOToggle/main.c 

* Author       : RF Application Team

* Version      : V1.1.0

* Date        : September-2015

* Description    : Code demostrating the GPIO functionality

********************************************************************************

* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS

* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.

* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,

* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE

* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING

* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

*******************************************************************************/

/* Includes ------------------------------------------------------------------*/

#include "bluenrg_x_device.h"

#include "BlueNRG1_conf.h"

#include "SDK_EVAL_Config.h"

#include <stdio.h>

#include <string.h>

/** @addtogroup BlueNRG1_StdPeriph_Examples

 * @{

 */

/** @addtogroup GPIO_Examples GPIO Examples

 * @{

 */

/** @addtogroup GPIO_InputInterrupt GPIO Input Interrupt Example

 * @{

 */

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

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

volatile uint32_t lSystickCounter=0;

/* Private function prototypes -----------------------------------------------*/

void SdkDelayMs(volatile uint32_t lTimeMs);

/* Private functions ---------------------------------------------------------*/

/**

 * @brief Main program code.

 * @param None

 * @retval None

 */

int main(void)

{

SdkDelayMs(4000);

 /* System initialization function */

 SystemInit();

  

 /* Identify BlueNRG1 platform */

 SdkEvalIdentification();

  

 /* Enable the GPIO Clock */

 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_GPIO, ENABLE);

  

 /* Configure the LEDs */

 GPIO_InitType GPIO_InitStructure;

 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 ;

 GPIO_InitStructure.GPIO_Mode = GPIO_Output;

 GPIO_InitStructure.GPIO_Pull = ENABLE;

 GPIO_InitStructure.GPIO_HighPwr = ENABLE;

 GPIO_Init(&GPIO_InitStructure);

 /* Put the LEDs off */

 GPIO_WriteBit(GPIO_Pin_2, Bit_SET );

  

 /* Configure SysTick to generate interrupt */

 SysTick_Config(SYST_CLOCK/1000 - 1);  

  

 /* Infinite loop */

 while(1) {

  // GPIO_ToggleBits(GPIO_Pin_2);

 GPIO_WriteBit(GPIO_Pin_2, Bit_RESET );

  SdkDelayMs(2000);

 GPIO_WriteBit(GPIO_Pin_2, Bit_SET );

  SdkDelayMs(2000);

 }

}

/**

* @brief Delay function

* @param Delay in ms

* @retval None

*/

void SdkDelayMs(volatile uint32_t lTimeMs)

{

 uint32_t nWaitPeriod = ~lSystickCounter;

  

 if(nWaitPeriod<lTimeMs)

 {

  while( lSystickCounter != 0xFFFFFFFF);

  nWaitPeriod = lTimeMs-nWaitPeriod;

 }

 else

  nWaitPeriod = lTimeMs+ ~nWaitPeriod;

  

 while( lSystickCounter != nWaitPeriod ) ;

}

#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

 */

void assert_failed(uint8_t* file, uint32_t line)

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

 /* Infinite loop */

 while (1)

 {

 }

}

#endif

/**

 * @}

 */

/**

 * @}

 */

/**

 * @}

 */

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

1 REPLY 1
pankajauengg
Associate II

The Pin Voltage not toggling