Reply
Posts: 67
Registered: ‎11-03-2016

Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

This is a very weird issue.

 

I started working with the SLWSTK6222A_ezradio_simple_trx generated by SS4 in a Silabs Dev Board. I want to migrate the code to a custom board and this new board does not have any button or LED so I want to get rid of the code used for the LEDs and the buttons.

 

But I noticed that when I delete the line

BSP_LedsInit();

from the code, the code continues to work but radio stops receiving.

 

I thought that it was because if I delete that function call, I'm deleting these two lines inside:

CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);

but copying those lines and putting them in the main function does not solve the problem.

 

These are the complete contents of that function:

int BSP_LedsInit(void)
{
  int i;

  CMU_ClockEnable(cmuClock_HFPER, true);
  CMU_ClockEnable(cmuClock_GPIO, true);
  for ( i=0; i<BSP_NO_OF_LEDS; i++ )
  {
    GPIO_PinModeSet(ledArray[i].port, ledArray[i].pin, gpioModePushPull, 0);
  }
  return BSP_STATUS_OK;
}

So there is not much going on there, nothing that could affect the radio reception, at least that can be deducted from looking at the contents of this function.

 

Does anybody know what's going on here? I don't want to simply leave the LEDs init code in my code when I don't even have LEDs just to have code that works, that's not right.

 

Thanks!

Posts: 56
Registered: ‎12-02-2016

Re: Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

Please check if all of the LED/Button code such as initialization/control/query in your application have been removed.

If you only remove the initialization code for LED/Button while the control/query code for LED/Button is left, it'll not work well when the control/query code is executed.

Regards,

Yongsheng

Posts: 67
Registered: ‎11-03-2016

Re: Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

@Yongsheng

 

It turns out that the code I need that is inside BSP_LedsInit() is this:

 

CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);

So if I delete BSP_LedsInit() and therefore the code mentioned above, then the radio does not receive. I'm not using LEDs or any I/O pin at all. So why deleting this piece of code messes up the radio reception?

Highlighted
Posts: 3,021
Registered: ‎02-07-2002

Re: Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

Did you try to look up what these two clocks refer to? I'm sure that if you do, it will be obvious to you why you need at least one of them.

Posts: 67
Registered: ‎11-03-2016

Re: Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

@vanmierlo

 

I was looking into the RM and the first statement is enabling the High-Frequency Peripheral Clock (HFPERCLK) and the second one is enabling the GPIO Clock.

 

I looked into the CMU_HFPERCLKEN0 - High-Frequency Peripheral Clock Register 0 in the reference manual and I can't find any reference to the internal EZRadioPRO.

 

So I'm asking because I haven't been able to find any relationship between these two lines of code and the lack of reception in the radio.

 

The other point I'm trying to make is that if there was any relationship between these two lines of code and the correct functionality of the radio, then this shall be taken care of in the ezradioInit() API. Because right now it seems that I had to use the MCU GPIOs if I want to have a functional radio or better said, I have to initialize the LEDs (non-existent in a custom board) if I want to use the radio and that seems wrong.

 

So I think there is something missing here because I think that the radio should be fully functional after being initialized with the ezradioInit() API.

 

So, what am I missing?

Posts: 3,021
Registered: ‎02-07-2002

Re: Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

I agree that the library code should enable all necessary clocks or the example should enable them in plain sight before as a prerequisite. Hiding this inside the LED functions is not right.

 

Further, remember the EZR32 is just an EFM32 with a radio glued on top inside one package with an SPI interface in between. So the EFM32 SPI pads are not routed to external pins but to the radio. But they still are normal pins and thus should be configured for input or output as if the radio was a separate chip on the board. For this the GPIO clock is required to access the mode register. The HFPERCLK is required for practically everything you do.

Posts: 56
Registered: ‎12-02-2016

Re: Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

What's the kit's number? Do you use the standard dev kit which is provided by Silabs? 
If it is, tell me and I'll make a project for you later. If not, please provide your own project, I'll check it.

Regards,
Yongsheng
Posts: 67
Registered: ‎11-03-2016

Re: Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

@Yongsheng @vanmierlo

 

Yesterday I was deleting lines of code in a trial-error fashion to be able to identify the code that is not needed. It turns out that I had to have BSP_LedsInit() as well as GpioSetup() in my code to make it work.

 

When I originally posted this question I thought that the lines

CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);

were causing the code not to work properly, Nevertheless, inside GpioSetup() there is a call to GPIOINT_Init() that in turn has

NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
NVIC_EnableIRQ(GPIO_ODD_IRQn);
NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
NVIC_EnableIRQ(GPIO_EVEN_IRQn);

inside.

 

I mention this because I deleted the line:

CMU_ClockEnable(cmuClock_GPIO, true);

and the code worked fine. Then I deleted:

CMU_ClockEnable(cmuClock_HFPER, true);

and to my surprise, the code still worked. So I came to the conclusion that the code that was really making the project work is the one inside GPIOINT_Init().

 

So I started to delete code from there. I started with:

NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
NVIC_EnableIRQ(GPIO_EVEN_IRQn);

and the code still worked fine. But then when I deleted:

NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
NVIC_EnableIRQ(GPIO_EVEN_IRQn);

the code then stopped working. So I added again those two last lines and the code worked again normally.

 

I read through the RM and I couldn't find why I need to enable the GPIO_ODD interrupts to make it work.

 

Maybe now that I've narrowed it down to this you could help me figure it out. This happens with both a custom board I have and the development kit. The Dev kit I'm using is the SLWSTK6222A.

 

The code I'm using is derived from the SLWSTK6222A_ezradio_simple_trx example generated by SS4.

 

Thanks!

Posts: 56
Registered: ‎12-02-2016

Re: Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

@mmalagon

1. I created a same project based on MCU SDK v5.2.1 which is the latest sdk. There's no BSP_LedsInit()  in the project. I don't know why you talked about BSP_LedsInit() . Did you use the latest sdk? If not, please update sdk to the latest version. Another notice is to open radio config file (the *.isc file under the branch of RadioConfig.) , modify the paramters if you want and click "Generate" before you build the project.

2. The reason for initializing GPIO_ODD_IRQn is some exit interrupt sources which are used for button/radio in the code are the pins with odd number. About the introduction of GPIO_ODD and GPIO_EVEN, please refer to chapter 32.3.5 Interrupt Generation of the chip's RM. Below are the related parts about button/radio.

Button pin. Maybe you have already removed the button's function.

Radio IRQ pin. You could find it through "ezradioInit(appRadioHandle);" -> "ezradio_hal_GpioInit(GPIO_EZRadio_INT_IRQHandler, true);" -> "GPIO_PinModeSet( (GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, gpioModeInputPull, 1);".

 

Regards,

Yongsheng

Posts: 56
Registered: ‎12-02-2016

Re: Why does the radio inside a EZR32WG fails to initialize when I remove the BSP_LEDSInit call?

 

Button pin. Maybe you have already removed the button's function.

01.png

Radio IRQ pin. You could find it through "ezradioInit(appRadioHandle);" -> "ezradio_hal_GpioInit(GPIO_EZRadio_INT_IRQHandler, true);" -> "GPIO_PinModeSet( (GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, gpioModeInputPull, 1);".

02.png