This post was last edited by Zhixin Studio on 2020-11-18 14:38
Since the Bluetooth ECG recording module developed by this studio uses nrf52832 as the main control chip, some problems encountered during the development process will be shared with you one by one:
The following figure is the pin diagram of the nrf52832 chip QFN48 package
Among them, P0.02~P0.05 and P0.28~P0.31 can be configured as ADC acquisition pins, and other IO pins can be arbitrarily assigned to various peripherals
P0.09 and P0.10 are assigned to NFC peripherals by default. If you need to set them as normal IO or map them to other peripherals, you need to add the macro CONFIG_NFCT_PINS_AS_GPIOS
P0.21 is used as the reset pin by default. If you need to set it as a normal IO or map it to other peripherals, you need to delete the macro CONFIG_GPIO_AS_PINRESET
However, after actual debugging, it is invalid after deletion. Debug observation found that PSELRESET is still connected to the default reset pin
I searched the source code and found that the following if statement is always invalid, so I need to manually modify NRF_UICR->PSELRESET[0] NRF_UICR->PSELRESET[1] to the required reset pin or disconnect it. When I was debugging, I directly modified the register to the empty IO pin.
Since this register is not lost when power is off, it can be modified normally
/* Bit 31 : Connection */
#define UICR_PSELRESET_CONNECT_Pos (31UL) /*!< Position of CONNECT field. */
#define UICR_PSELRESET_CONNECT_Msk (0x1UL << UICR_PSELRESET_CONNECT_Pos) /*!< Bit mask of CONNECT field. */
#define UICR_PSELRESET_CONNECT_Connected ( 0UL) /*!< Connect */
#define UICR_PSELRESET_CONNECT_Disconnected (1UL) /*!< Disconnect */
#if defined (CONFIG_GPIO_AS_PINRESET)
if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) ||
((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk ) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos ))) {
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_UICR->PSELRESET[0] = 0xffff;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_UICR->PSELRESET[1] = 0xffff;
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
Serial communication pin
When configuring serial communication, when the serial port receiving pin is left unconnected and reception is enabled, errors may occur, causing the program to die in the serial port receiving error. This can be solved by connecting a pull-up resistor to the RX pin.
Since the 32768 clock is normally used, no IO configuration is made