Professional Documents
Culture Documents
**************************************************************************//**
Name: Ramnarayan Krishnamurthy
Date: 1/27/2016
ECEN 5023: Assignment 1
Write and debug a Low Energy program with the following requirements:
1) LED blinks with the period of 2 seconds
2) LED is on for 2.5% of the time or 2.5% duty cycle
*****************************************************************************/
#include "mbed.h"
#include "em_chip.h"
#include "em_emu.h"
#include "em_pcnt.h"
#include "em_letimer.h"
/*Time Period and LED on Period input for the compare registers */
#define DESIREDPERIOD 2000
/*For a duty cycle of 2.5% = 2.5/100 * 2000 = 50 */
#define LEDONDUTYCYCLE 50
void BSP_TraceSwoSetup(void)
{
/* Enable GPIO clock */
CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
DigitalOut myLed0(LED0);
DigitalOut myLed1(LED1);
void LETIMER0_IRQHandler(void)
{
/* Clear LETIMER0 comp0 interrupt flag */
myLed0=!myLed0;
int main(void)
{
/* Chip errata */
CHIP_Init();
/* The intial condition can be switched to 0 for a duty cycle of 100present cycle*/
myLed0=1;
CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_ULFRCO);
LETIMER_IntEnable(LETIMER0, LETIMER_IF_COMP0|LETIMER_IF_COMP1);
NVIC_EnableIRQ(LETIMER0_IRQn);
LETIMER_CompareSet(LETIMER0, 0, DESIREDPERIOD);
LETIMER_CompareSet(LETIMER0, 1, LEDONDUTYCYCLE);
LETIMER_RepeatSet(LETIMER0, 0, 0x01);
LETIMER_RepeatSet(LETIMER0, 0, 0x01);
/* Initialize LETIMER0 */
LETIMER_Init(LETIMER0, &letimerInit);
while (1)
{
/*Go to EM3 and wakes up when interrupted*/
EMU_EnterEM3(false);
}
}