Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

GPIO commands for Blinking LED problem in simplisity studio

yefj

Advanced Member level 4
Joined
Sep 12, 2019
Messages
115
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
809
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
14,189
Helped
4,685
Reputation
9,385
Reaction score
4,439
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
121,167
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 2
Joined
Jan 25, 2019
Messages
693
Helped
169
Reputation
338
Reaction score
167
Trophy points
43
Activity points
5,023
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
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top