Those pits encountered when using EFM32PG1B

Pit 1: Pin function definition

 The company's project needs to use the EFM32 series of single-chip microcomputers. At first glance at the chip manual, when I saw the pin definitions, I was really confused
Here is an example of serial port one pin
 . The first impression at first glance is that these pins all have serial port functions? Is it so free? Yes, it is so free. I take the sending pin of serial port 1 as an example to illustrate, namely US1_TX, here to say, the serial port pin and SPI pin of EFM32 are multiplexed. When using the function library, we can also see SPI and serial port sending The register to be called is also the same, which is actually more convenient. There are 32 pins on the right side of US1_TX, all of which can be used as sending pins of serial port one.
 How should the code layer be implemented? We can see that each pin has a serial number such as 0:PA0. When we need to use PA0 as a sending pin:

	USART0->ROUTELOC0 = (USART0->ROUTELOC0 & (~_USART_ROUTELOC0_TXLOC_MASK))
			| USART_ROUTELOC0_TXLOC_LOC0;

 Just configure the USART0->ROUTELOC0 register to USART_ROUTELOC0_TXLOC_LOC0 (label corresponding). If you want to use 4:PA4, then configure it to USART_ROUTELOC0_TXLOC_LOC4. It’s ok. I ca
 n’t help but want to complain about it. Of course, I didn’t find it myself. I have been unable to find the manual of the register. If there is a clear Programmer.pdf, it will be too easy. After all, it is too difficult to cross the river by feeling the stones. The simple datasheet is a bit too weak.

Pit 2: The use of external interrupts

 There are two external interrupts for EFM32, one is GPIO_EVEN_IRQn and the other is GPIO_ODD_IRQn. For STM32, the external interrupt is divided into LINE0, LINE1, etc. according to the number of pins. Our little gecko is a bit naughty. It simply divides all interrupt lines into two categories, odd-numbered pin lines and even-numbered pin lines. EVEN_IRQn is an even-numbered pin interrupt, ODD_IRQn is an odd-numbered pin interrupt. After entering the interrupt, directly perform judgment and clear interrupt operations:

/**************************************************************************//**
 * @brief GPIO Interrupt handler
 *****************************************************************************/
void GPIO_EVEN_IRQHandler(void)
{
    
    
	uint32_t flags;
	flags = GPIO_IntGet();
	GPIO_IntClear(flags);
}
/**************************************************************************//**
 * @brief GPIO Interrupt handler
 *****************************************************************************/
void GPIO_ODD_IRQHandler(void)
{
    
    
	uint32_t flags;
	flags = GPIO_IntGet();
	GPIO_IntClear(flags);
}

 Personally, I don't really like to use the official library. In many cases, it is OK to directly configure the register. There is no need to call complex library functions. Most library functions must meet compatibility, so the complexity of library functions increases. So I still recommend using more register operations when there is plenty of time to reduce code execution efficiency.

Official website link

You can find information such as
Pearl Gecko Device official website to connect

Guess you like

Origin blog.csdn.net/m0_38127906/article/details/107140810