This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Missing NFC pin deactivation on pca10040e for nRF52810

During developpement of project on nRF52810, we used the nRF52DK PCA10040.

Since we wanted to use P0.9 and P0.10 (to limit differences between eval-board and real board), we did the hardware modifications to be able to use those pins as GPIOs.

We also set CONFIG_NFCT_PINS_AS_GPIOS define but without success. In fact the system_nrf52810 misses its handling.

Here's the patch that compile and works (i.e. my SPI using P0.7→P0.10 does work).

diff --git a/redacted/nrf52810/nrf-sdk/modules/nrfx/mdk/system_nrf52810.c b/redacted/nrf52810/nrf-sdk/modules/nrfx/mdk/system_nrf52810.c
index d0cf25b..033b306 100644
--- a/redacted/nrf52810/nrf-sdk/modules/nrfx/mdk/system_nrf52810.c
+++ b/redacted/nrf52810/nrf-sdk/modules/nrfx/mdk/system_nrf52810.c
@@ -25,6 +25,10 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA.
 
 #include <stdint.h>
 #include <stdbool.h>
+#if defined(DEVELOP_IN_NRF52832)
+#undef NRF52810_XXAA
+#define NRF52832_XXAA
+#endif
 #include "nrf.h"
 #include "system_nrf52810.h"
 
@@ -35,7 +39,6 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA.
 static bool errata_31(void);
 static bool errata_36(void);
 static bool errata_66(void);
-static bool errata_103(void);
 static bool errata_108(void);
 static bool errata_136(void);
 
@@ -47,6 +50,8 @@ static bool errata_32(void);
 static bool errata_37(void);
 static bool errata_57(void);
 static bool errata_182(void);
+#else
+static bool errata_103(void);
 #endif
 
 #if defined ( __CC_ARM )
@@ -163,11 +168,13 @@ void SystemInit(void)
         NRF_TEMP->T4 = NRF_FICR->TEMP.T4;
     }
     
+    #if !defined(DEVELOP_IN_NRF52832)
     /* Workaround for Errata 103 "CCM: Wrong reset value of CCM MAXPACKETSIZE" found at the Errata document
        for your device located at https://www.nordicsemi.com/DocLib  */
     if (errata_103()){
         NRF_CCM->MAXPACKETSIZE = 0xFBul;
     }
+    #endif
 
     /* Workaround for Errata 108 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document
        for your device located at https://www.nordicsemi.com/DocLib  */
@@ -191,6 +198,20 @@ void SystemInit(void)
     }
     #endif
 
+
+    #if defined (DEVELOP_IN_NRF52832)
+        /* Configure NFCT pins as GPIOs since there is no NFC. */
+        if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
+            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
+            while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
+            NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
+            while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
+            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
+            while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
+            NVIC_SystemReset();
+        }
+    #endif
+
     /* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
       defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
       reserved for PinReset and not available as normal GPIO. */
@@ -368,6 +389,7 @@ static bool errata_66(void)
     return true;
 }
 
+#if !defined(DEVELOP_IN_NRF52832)
 static bool errata_103(void)
 {
     if (*(uint32_t *)0x10000130ul == 0xAul){
@@ -378,6 +400,7 @@ static bool errata_103(void)
 
     return false;
 }
+#endif
 
 static bool errata_108(void)
 {

Not sure there is a better patch (undefining and re-defining NRF52xxx_XXAA). Maybe the target (_XXAA or _XXBB) should be configurable.

The code/diff is based on SDK15.2.0, but looks that there is no NFC handling in SDK15.3.0 (besides errata 57 from nRF52).

Parents Reply Children
Related