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 2
Joined
Sep 12, 2019
Messages
650
Helped
0
Reputation
0
Reaction score
2
Trophy points
18
Activity points
3,551
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);


  }
}
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
15,728
Helped
5,067
Reputation
10,159
Reaction score
4,924
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
133,197
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.
 

wwfeldman

Advanced Member level 4
Joined
Jan 25, 2019
Messages
1,058
Helped
222
Reputation
443
Reaction score
282
Trophy points
83
Activity points
8,054
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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top