GPIO_DriveModeSet
Answer
2/8/18 9:21 PM

Hello everyone

I'm trying the LED blinking functionality on the Extension bus (Led task) but I can not achieve to turn on the LED, I read the port need to set the current of the GPIO port in High, and I used GPIO_DriveModeSet, but the LED is not working, anyone has tried before that?

I measured the voltage in PA1, and I read 2.54 V, but when I stepped the current, it was below 0.06 mA, or maybe did I put wrong the connection to the LED? I understand there is a resistor protection of 40 ohms, I attached an image of the connection.

Here is the code:

#include <stdio.h>
#include "FreeRTOS.h"
#include "timers.h"
#include "BCDS_MCU_GPIO.h"          // header for extender board
#include "BCDS_MCU_GPIO_Handle.h"   // header fos extender board handle
#include "LedExtBrd.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_Assert.h"

void extensionLedTask(void)
{
        int count = 0;
	MCU_GPIO_Handle_T GPIOA;        
        //GPIO_DriveModeSet(GPIO_Port_TypeDef port, GPIO_DriveMode_TypeDef mode)
	GPIO_DriveModeSet(gpioPortA, gpioDriveModeHigh);	
	GPIOA.Port = gpioPortA;
	GPIOA.Pin = 1;
	GPIOA.Mode = gpioModePushPullDrive;
	GPIOA.InitialState = MCU_GPIO_PIN_STATE_HIGH;

	/* initialization activities for PTD driver */
	MCU_GPIO_Initialize(&GPIOA);
	//https://siliconlabs.github.io/Gecko_SDK_Doc/efm32g/html/group__GPIO.html

	/* blinking function */
	while (count < 10000)
	{
		MCU_GPIO_WritePin(&GPIOA, MCU_GPIO_PIN_STATE_HIGH);
		printf("ON\n\r");
		vTaskDelay(10000);
		MCU_GPIO_WritePin(&GPIOA, MCU_GPIO_PIN_STATE_LOW);
		printf("OFF\n\r");
	        vTaskDelay(10000);	  
	        count++;
	}
}

void appInitSystem(void * CmdProcessorHandle, uint32_t param2)
{
    if (CmdProcessorHandle == NULL)
    {
        printf("Command processor handle is null \n\r");
        assert(false);
    }
    BCDS_UNUSED(param2);
    extensionLedTask();
}

 

0 (0 Votes)
RE: GPIO_DriveModeSet
Answer
2/11/18 3:46 AM as a reply to Rolando Gonzalez.

Ignore that, I found the solution here:

https://xdk.bosch-connectivity.com/community/-/message_boards/message/323117

Thanks!

The code modified is here and works over Workbench version 3.1.0:

#include <stdio.h>
#include "FreeRTOS.h"
#include "timers.h"
#include "BCDS_MCU_GPIO.h"          // header for extender board
#include "BCDS_MCU_GPIO_Handle.h"   // header fos extender board handle
#include "LedExtBrd.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_Assert.h"

void extensionLedTask(void)
{
	MCU_GPIO_Handle_T GPIOA;
	/* initialize local variables */
	int count = 0;
	GPIOA.Port = gpioPortA;
	GPIOA.Pin = 1;
	GPIOA.Mode = gpioModePushPullDrive;
	GPIOA.InitialState = MCU_GPIO_PIN_STATE_HIGH;
	//MCU_GPIO_Initialize(&GPIOA); // Before
	GPIO_DriveModeSet(gpioPortA, gpioDriveModeHigh);
	GPIO_PinModeSet(GPIOA.Port, GPIOA.Pin, GPIOA.Mode, GPIOA.InitialState);
	/* initialization activities for PTD driver */
	//https://siliconlabs.github.io/Gecko_SDK_Doc/efm32g/html/group__GPIO.html

	/* blinking function */
	while (count < 10000)
	{
		/* set data out register for the pin to 1 */
		MCU_GPIO_WritePin(&GPIOA, MCU_GPIO_PIN_STATE_HIGH);
		printf("ON\n\r");
		vTaskDelay(500);
		/* use suitable delay API). This delay API is only for demo */
		/* set data out register for the pin to 0 */
		MCU_GPIO_WritePin(&GPIOA, MCU_GPIO_PIN_STATE_LOW);
		printf("OFF\n\r");
	    vTaskDelay(500);
	    /* use suitable delay API). This delay API is only for demo */
	    count++;
	}
}

void appInitSystem(void * CmdProcessorHandle, uint32_t param2)
{
    if (CmdProcessorHandle == NULL)
    {
        printf("Command processor handle is null \n\r");
        assert(false);
    }
    BCDS_UNUSED(param2);

    extensionLedTask();
}

 

0 (0 Votes)
RE: GPIO_DriveModeSet
Answer
2/9/18 2:00 PM as a reply to Rolando Gonzalez.
Hello Rolando,

First, I like to welcome you to the XDK community.

I am glad to hear that you were able to solve the issue by yourself.

Please feel free to ask if you have further questions or concerns.

Kind regards,
Franjo
0 (0 Votes)