Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GPIO commands for Blinking LED problem in simplisity studio

Status
Not open for further replies.

yefj

Advanced Member level 4
Joined
Sep 12, 2019
Messages
1,190
Helped
1
Reputation
2
Reaction score
3
Trophy points
38
Activity points
7,182
Hello, i have the following commands
GPIO_PinOutClear(LED_PORT_E,15)
GPIO_PinModeSet(LED_PORT_A,15,gpioModePushPull,0)
GPIO_PinOutSet(LED_PORT_E,15)

I know that i should put ON value delay OFF value in a loop in order to make the LEDs blink constantly.
I have tried to implement it ,but its not working.
Where did i go wrong?
Thanks.

Code:
#include <stdint.h>
#include <stdbool.h>
#include "em_device.h"
#include "em_chip.h"
#include "em_cmu.h"
#include "em_emu.h"
#include "bsp.h"
#include "bsp_trace.h"

#define LED_PORT_E    gpioPortE
#define LED_PIN_E     15

#define LED_PORT_A    gpioPortA
#define LED_PIN_A     15

volatile uint32_t msTicks; /* counts 1ms timeTicks */

void Delay(uint32_t dlyTicks);

/***************************************************************************//**
 * @brief SysTick_Handler
 * Interrupt Service Routine for system tick counter
 ******************************************************************************/
void SysTick_Handler(void)
{
  msTicks++;       /* increment counter necessary in Delay()*/
}

/***************************************************************************//**
 * @brief Delays number of msTick Systicks (typically 1 ms)
 * @param dlyTicks Number of ticks to delay
 ******************************************************************************/
void Delay(uint32_t dlyTicks)
{
  uint32_t curTicks;

  curTicks = msTicks;
  while ((msTicks - curTicks) < dlyTicks) ;
}

/***************************************************************************//**
 * @brief  Main function
 ******************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();
CMU_ClockEnable(cmuClock_GPIO,true);
  /* If first word of user data page is non-zero, enable Energy Profiler trace */
  BSP_TraceProfilerSetup();

  /* Setup SysTick Timer for 1 msec interrupts  */
  if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) {
    while (1) ;
  }

  /* Initialize LED driver */

  BSP_LedsInit();
  BSP_LedSet(0);
  GPIO_PinModeSet(LED_PORT_A,15,gpioModePushPull,0);
  Delay(1000);
  GPIO_PinModeSet(LED_PORT_E,15,gpioModePushPull,0);

  while (1) {
      GPIO_PinOutClear(LED_PORT_E,15);

      GPIO_PinOutSet(LED_PORT_E,15);


  }
}
 

I have no experience with Simplisity Studio but looking at the code as generic 'C', I would have thought something to identify "SysTick_Handler" as an interrupt routine would be needed.

Brian.
 

i am not familiar with Simplicity Studio either, but a generic C comment:

your code:
/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) {
while (1) ;
}

i would have expected something to happen for the while(1)
as it is, the if statement, when true, executes a while(1), which
doesn't do anything

likewise:
while (1) {
GPIO_PinOutClear(LED_PORT_E,15);

GPIO_PinOutSet(LED_PORT_E,15);
}

you set and clear the pin, which presumably drives the LED
but it will execute at the clock speed and i doubt you will see anything
like you said at the beginning of the first post, you need clear, delay, set, delay
 

    yefj

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top