Reply
Posts: 8
Registered: ‎04-13-2017
Accepted Solution

Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

Dear all,

 

I need assistance to configure P3.2 (connected to EXP_HEADER 9)  as a push-pull digital output on EFM8LB12F64 Laser Bee Starter Kit (Rev A00). 

 

I use KEIL IDE uV5.

 

Can somebody help me to identify the problem? P0.0 blinks as expected, but P3.2.

 

The code is very very simple one;

 

 

#include <SI_EFM8LB1_Register_Enums.h>

 

sbit LED1= P0^0;
sbit LED2= P3^2;
int i,j;

MCU_init(){
// TO disable watchdog timer do following
WDTCN = 0xDE;
WDTCN = 0xAD;
//now, watchdog disabled


CLKSEL = 0X80; // System Clock = 24.5 MHZ
HFOCN = HFOCN |0x08; // Enable HF oscillator


P0MDIN = P0MDIN | 0x01;
P0MDOUT = P0MDOUT | 0x01;

 

P3MDIN = P3MDIN | 0x0F;
P3MDOUT = P3MDOUT | 0x0F;

XBR2=0x40; // Enable Crossbar
}

 

main() {

MCU_init();
LED1=0;
LED2=1;
while(1){
for(i=0;i<25000;i++) {
for(j=0;j<100;j++) { }}

LED1 = ~LED1;
LED2 = ~LED2;
}

}

Posts: 8,067
Registered: ‎08-13-2003

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

i see nothing wrong with the  code, triple check your connections

erik
Posts: 1,955
Registered: ‎10-14-2014

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

#include <SI_EFM8LB1_Register_Enums.h>
 
sbit LED1= P0^0;
sbit LED2= P3^2;
int i,j;

MCU_init()
{
	// TO disable watchdog timer do following
	WDTCN = 0xDE;
	WDTCN = 0xAD;
	//now, watchdog disabled

	CLKSEL = 0X80; // System Clock = 24.5 MHZ
	HFOCN = HFOCN |0x08; // Enable HF oscillator


	P0MDIN = P0MDIN | 0x01;
	P0MDOUT = P0MDOUT | 0x01;
	 
	P3MDIN = P3MDIN | 0x0F;
	P3MDOUT = P3MDOUT | 0x0F;

	XBR2=0x40; // Enable Crossbar
}
 
main() 
{

	MCU_init();
	LED1=0;
	LED2=1;
	while(1)
	{
		for(i=0;i<25000;i++) 
		{
			for(j=0;j<100;j++) 
			{ 
			}
		}

		LED1 = ~LED1;
		LED2 = ~LED2;
	}
}

Re-upload the code by "insert code" for better visibility.

Yes, I did not see anything wrong in the code, I did not figure out anything special on the schemtaic of the STK board either that could explain this observation.
Maybe need try to reproduce this first on the STK board and debug to figure out the root cause.

WeiguoLu
Posts: 1,955
Registered: ‎10-14-2014

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

I tried the LB1 STK with below code by Simplicity Studio and I could see P3.2 toggle as expected.

//------------------------
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <SI_EFM8LB1_Register_Enums.h>

//-----------------------------------------------------------------------------
// Pin Definitions
//-----------------------------------------------------------------------------
SI_SBIT (LED7, SFR_P0, 0);                 // LED='1' means ON
SI_SBIT (LED8, SFR_P3, 2);
///sbit LED1= P0^0;
///sbit LED2= P3^2;

void MCU_init(void )
{
    // TO disable watchdog timer do following
    WDTCN = 0xDE;
    WDTCN = 0xAD;
    //now, watchdog disabled

    CLKSEL = 0X80; // System Clock = 24.5 MHZ
    HFOCN = HFOCN |0x08; // Enable HF oscillator


    P0MDIN = P0MDIN | 0x01;
    P0MDOUT = P0MDOUT | 0x01;

    P3MDIN = P3MDIN | 0x0F;
    P3MDOUT = P3MDOUT | 0x0F;

    XBR2=0x40; // Enable Crossbar
}

//-----------------------------------------------------------------------------
// Main Routine
//-----------------------------------------------------------------------------
void main (void)
{
   //enter_DefaultMode_from_RESET();

   //DISP_EN = DISP_BC_DRIVEN;           // Display not driven by EFM8
    int i, j;
    MCU_init();
    LED7=0;
    LED8=1;
    while(1)
    {
        for(i=0;i<5000;i++)
        {
            for(j=0;j<100;j++)
            {
                ;
            }
        }

        LED7 = !LED7;
        LED8 = !LED8;
    }
   IE_EA = 1;                          // Enable global interrupts

   while (1) {}                        // Spin forever
}

 

WeiguoLu
Posts: 8
Registered: ‎04-13-2017

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

Thanks for the response! It looks good that your board is functional. Let me explain my case:

 

1. I don't use Simplicity Studio

2. I use KEIL uv5

 

So the code provided doesn't 100% reflect my case.

 

Would you, please, try with uv5?

 

PS: I checked exp header  to CPU connections by an ohmmeter. All O.K.

      The board is good with the examples that are provided in Simplicity Studio

 

Best regards!

Posts: 8,067
Registered: ‎08-13-2003

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

Would you, please, try with uv5?

 

since SiLabs provide a free Keil running under SS, rather than uv I doubt many have uv5

erik
Posts: 8
Registered: ‎04-13-2017

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

I tried the code below in SS. P0.0 is toggling, but P3.2.

 

#include <SI_EFM8LB1_Register_Enums.h>             

int i,j;

MCU_init(){
       WDTCN = 0xDE;
       WDTCN = 0xAD;

CLKSEL =  0X80;                 // System Clock = 24.5  MHZ
HFOCN = HFOCN |0x08;            // Enable HF oscillator

P3MDIN = P3MDIN | 0x0F;
P3MDOUT = P3MDOUT | 0x0F;
P0MDIN = P0MDIN | 0x0F;
P0MDOUT = P0MDOUT | 0x0F;

XBR2=0x40;                      // Enable Crossbar
}

SI_SBIT (LED2, SFR_P3, 2);
SI_SBIT (LED1, SFR_P0, 0);

void main (void)
{
       MCU_init();

   while (1) {

              for(i=0;i<25000;i++) {
              for(j=0;j<100;j++) {     }}
              LED2=~LED2;
              LED1=~LED1;
   }
}

 

Posts: 1,955
Registered: ‎10-14-2014

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

@abraham

Your code works fine on my side with SS+EFM8LB STK.

 

WeiguoLu
Posts: 8
Registered: ‎04-13-2017

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

So, it is obvious that my board is problematic though it has never been used before. 

 

I don't know if I could return it

 

Robot Sad 

Posts: 8,067
Registered: ‎08-13-2003

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

just a thought

what do/did you have connected to the nonworking pin?

erik
Posts: 8
Registered: ‎04-13-2017

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

Just a LED with a resistor that are connected in series. 

Posts: 8,067
Registered: ‎08-13-2003

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

connected to gnd or 3V3?

erik
Posts: 1,955
Registered: ‎10-14-2014

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

I suggest you probe the pin with a scope. the p3.2 is available in the expsion port but did noy connect any led at default.
WeiguoLu
Highlighted
Posts: 8
Registered: ‎04-13-2017

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

I checked by a multimeter as well. No chance Robot Sad

I shall replace the cpu
Posts: 8
Registered: ‎04-13-2017

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

sir,

 

I have bought a new EFM8LB12F64E QFP32 and soldered it onto a QFP to DIP adapter for breadboarding. 

 

I can download and erase the MCU by debug adapter within KEIL uVision 5. I can toggle any pin at P0, P1 or P2, but, P3.

 

I failed with the new chip as well. I checked almost everywhere in reference manual, but, failed to identify the problem.

 

Do you have a good idea?

Posts: 8
Registered: ‎04-13-2017

Re: Failed to use pins P3.0 and P3.1 on EFM8LB12F64 Laser Bee Starter Kit

nobody there? Any opinion?