IO pin function setting

Post Reply
workman
Posts: 7
Joined: 16 Oct 2018, 17:39

31 Oct 2018, 11:06

What difference between the following code?
SYS->GPA_MFPH &= ~(SPI2_SS_PA11_Msk | SPI2_CLK_PA10_Msk | SPI2_MOSI_PA8_Msk | SPI2_MISO_PA9_Msk);
SYS->GPA_MFPH |= SPI2_SS_PA11 | SPI2_CLK_PA10 | SPI2_MOSI_PA8 | SPI2_MISO_PA9;
and
SYS->GPA_MFPL = SYS_GPA_MFPH_PA11MFP_SPI2_SS | SYS_GPA_MFPH_PA8MFP_SPI2_MOSI | SYS_GPE_MFPH_PE9MFP_SPI2_MISO | SYS_GPA_MFPH_PA10MFP_SPI2_CLK;

ycchen
Posts: 2
Joined: 08 Nov 2018, 10:02

09 Nov 2018, 10:46

The first writing method configures PA.9~PA.11 function only.
For the sencond writing method, it will overwrite others IO setting, which are not assigned, to GPIO. (for example, PA.8 and PA.12~PA.15).
It is recommonded to use the first method to avoid configuration overwriting.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests