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.

Simple LED Blinky Code - EFM32 EB

Status
Not open for further replies.

Prabhu Durai

Newbie level 6
Joined
Mar 27, 2015
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
133
Hello Everyone,

i am working on the EFM32 EB and TELECOM DESIGN TD1204 my objective is to write the program for gps and accelerometer detection by using the this controller

can anyone help me to write the program and i have just wrote the simple LED blinking program but it shows me some error


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <efm32.h>
#include <em_gpio.h>
#include <td_rtc.h>
#include <td_core.h>
 
/* This file declare all "dynamic" library data. It should be last included file
 * Standard size value can be override before including this file
 */
#define TD_SENSOR_USE_CODE 0
#define TD_GEOLOC_USE_CODE 0
#include <td_config.h>
 
/*******************************************************************************
 *************************   DEFINES   *****************************************
 ******************************************************************************/
 
#define LED_PORT    TIM2_PORT           /**< LED port */
#define LED_BIT     TIM2_BIT            /**< LED bit */
 
/*******************************************************************************
 ******************************  CONSTANTS  ************************************
 ******************************************************************************/
 
/*******************************************************************************
 **************************   PUBLIC FUNCTIONS   *******************************
 ******************************************************************************/
 
/***************************************************************************//**
 * @brief
 *   User setup function.
 ******************************************************************************/
void TD_USER_Setup(void)
{
    // Define the LED pin as an output in push-pull mode
    GPIO_PinModeSet(LED_PORT, LED_BIT, gpioModePushPull, 1);
 
    // Forever
    while (true) {
 
        // Toggle the LED pin on/off
        GPIO_PinOutToggle(LED_PORT, LED_BIT);
 
        // Delay 500 ms
        TD_RTC_Delay(T500MS);
    }
 
    // Never reached
}
 
/***************************************************************************//**
 * @brief
 *   User loop function.
 ******************************************************************************/
void TD_USER_Loop(void)
{
    // Never called
}

 
Last edited by a moderator:

Post the datasheet of the device you're trying to communicate with.
 

Re: Requesting to help me to write the codinfor LED BLINKING

I want to write the coding for make the LED turn on if i press the button for 3 seconds and LED has to be turned off if o press the button for 5 seconds
can you help me with this controller
SDA -> PA0
SCL -> PA1
TIM2 -> PD7 ( this is the LED pin and i want to turn on this pin if is press the button for 3 seconds and 5 second means it ahs toturn off
ADC0 - > PD6
DAC0 -> PB11
 

Attachments

  • EFM32G-RM.pdf
    7.9 MB · Views: 70
  • TD1204 Datasheet rev1.3 (7).pdf
    267.3 KB · Views: 49
  • EFM32G210.pdf
    1.7 MB · Views: 49

It looks like the TD1204 uses UART and I2C to communicate - are you familiar with these protocols ?
 

yeah i am keep on learning those things but my first step is to make the led blinking if i press the button for three seconds and turn it off if i press the button for five seconds please help me so that i can improve my project further
 

You have to use Timer Interrupts. Which Compiler are you using ?
 

Is GGC Compiler a free compiler ? If yes, provide the download link for the Compiler. I will see if I can write a code for you. What IDE are you using to write the code ?
 
Last edited:

Thanks you for the reply am using EClipse IDE and it is downloadable here **broken link removed**
can you gudie how to write the coding to turn ON the LED if i press three seconds ?
 

Should I install the 500+ MB software in the TD_RF_Module_SDK Zip file ?
 

Hello everyone am trying to turn on the LED by using the timer and button interrupt function, my aim of the program is, if i press the button for 3secthen LED turn and also the LED will be turned off by pressing the button for 5 sec ,but for this program i am not getting the output please rectify the errors and i would appreciate your suggestions (efm32g210f128 is the controller)

#define LED_PORT TIM2_PORT /**< LED port *///gpio port D
#define LED_BIT TIM2_BIT /**< LED bit *///gpio pin7
#define BUTTON_PORT RX_PORT /**< Button port */
#define BUTTON_BIT RX_BIT /**< Button bit */
#define BUTTON_MASK RX_MASK /**< Button mask */
/*******************************************************************************
****************************** CONSTANTS ************************************
******************************************************************************/
/*******************************************************************************
************************* PRIVATE VARIABLES *******************************
******************************************************************************/
/** Button event flag */
static bool ButtonPressedEvent = false;

/*******************************************************************************
************************* PRIVATE FUNCTIONS *******************************
******************************************************************************/
/***************************************************************************//**
* @brief
* Button interrupt handler.
******************************************************************************/
static void ButtonInterrupt(uint32_t mask)
{
if(ButtonPressedEvent)
{
ButtonPressedEvent=true;
}
else
{
ButtonPressedEvent=false;
}
}
void timer0_Init() {
CMU_ClockEnable(cmuClock_TIMER0, true);
TIMER0->CTRL |= TIMER_CTRL_PRESC_DIV1024;
TIMER0->CTRL |= TIMER_CTRL_CLKSEL_PRESCHFPERCLK;
TIMER0->CTRL |= TIMER_CTRL_MODE_UP;
TIMER0->CTRL |= TIMER_CTRL_FALLA_START;
TIMER0->CTRL |= TIMER_CTRL_RISEA_STOP;
}
void timer0_Start() {
TIMER0->CMD = TIMER_CMD_START;
}
void timer0_Stop() {
TIMER0->CMD = TIMER_CMD_STOP;
}
/*******************************************************************************
************************** PUBLIC FUNCTIONS *******************************
******************************************************************************/
/***************************************************************************//**
* @brief
* User setup function.
******************************************************************************/
void TD_USER_Setup(void)
{
int type;
IRQn_Type irq_parity;
// Define the LED pin as an output in push-pull mode
GPIO_PinModeSet(LED_PORT, LED_BIT, gpioModePushPull, 0);
// Define the button pin as an input with an internal pull-up resistor
GPIO_PinModeSet(BUTTON_PORT, BUTTON_BIT, gpioModeInputPull, 1);
// Set up a user hook on button pin interrupt
type = (BUTTON_MASK & TD_GPIO_ODD_MASK) ?
TD_GPIO_USER_ODD : TD_GPIO_USER_EVEN;
TD_GPIO_SetCallback(type, ButtonInterrupt, BUTTON_MASK);

// Enable falling edge interrupts on button pin
GPIO_IntConfig(RX_PORT, RX_BIT, false, true, true);
// Enable Rising edge interrupts on button pin
GPIO_IntConfig(RX_PORT, RX_BIT, true, false, true);
// Clear and enable the corresponding interrupt in the CPU's Nested Vector
// Interrupt Controller
irq_parity =
(BUTTON_MASK & TD_GPIO_ODD_MASK) ? GPIO_ODD_IRQn : GPIO_EVEN_IRQn;
NVIC_ClearPendingIRQ(irq_parity);
NVIC_EnableIRQ(irq_parity);
}
/***************************************************************************//**
* @brief
* User loop function.
******************************************************************************/
void TD_USER_Loop(void)
{

CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO); //Use HF clock
timer0_Init();
while(1)
// If RX module pin goes low
if (ButtonPressedEvent==true)
{
// Turn ON the Timer
timer0_Start();
}
else
{
ButtonPressedEvent=false;
// Turn OFF the Timer
timer0_Stop();
}
if (TIMER_COUNT < 3)
{
// Turn on the LED
GPIO_PinOutSet(LED_PORT, LED_BIT);
}
else if (TIMER_COUNT > 5)
{
// Turn OFF the LED
GPIO_PinOutClear(LED_PORT, LED_BIT);
}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top