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

nrf_drv_pdm.h related issues with nrf51822+pdm.

Hello Team,

I am working on a project in which I want to used pdm microphone with nrf51822 xxAA and i am using keil u5.

1) So I have picked uart over BLE example from keil pack installer.

2) Then I have included the "nrf_drv_pdm.h" library.

3) After that I have changed #define PDM_ENABLED  from 0 to 1 in nrf_drv_config.h

And  after doing all these steps when I run build it is showing around 30 errors in nrf_pdm.h file like used of undeclared identifier 'NRF_PDM'.and many more.

Can you please help me/ direct me toward proper solutions.

Below is the build output error:

Build started: Project: ble_app_uart_s130_pca10028
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'nrf51422_xxac_s130'
compiling main.c...
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(43): error:  #20: identifier "NRF_PDM_Type" is undefined
      NRF_PDM_TASK_START           = offsetof(NRF_PDM_Type, TASKS_START),           ///< Starts continuous PDM transfer.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(43): error:  #29: expected an expression
      NRF_PDM_TASK_START           = offsetof(NRF_PDM_Type, TASKS_START),           ///< Starts continuous PDM transfer.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(43): error:  #18: expected a ")"
      NRF_PDM_TASK_START           = offsetof(NRF_PDM_Type, TASKS_START),           ///< Starts continuous PDM transfer.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(44): error:  #29: expected an expression
      NRF_PDM_TASK_STOP            = offsetof(NRF_PDM_Type, TASKS_STOP)             ///< Stops PDM transfer.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(44): error:  #18: expected a ")"
      NRF_PDM_TASK_STOP            = offsetof(NRF_PDM_Type, TASKS_STOP)             ///< Stops PDM transfer.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(53): error:  #29: expected an expression
      NRF_PDM_EVENT_STARTED       = offsetof(NRF_PDM_Type, EVENTS_STARTED),       ///< PDM transfer has started.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(53): error:  #18: expected a ")"
      NRF_PDM_EVENT_STARTED       = offsetof(NRF_PDM_Type, EVENTS_STARTED),       ///< PDM transfer has started.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(54): error:  #29: expected an expression
      NRF_PDM_EVENT_STOPPED       = offsetof(NRF_PDM_Type, EVENTS_STOPPED),       ///< PDM transfer has finished.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(54): error:  #18: expected a ")"
      NRF_PDM_EVENT_STOPPED       = offsetof(NRF_PDM_Type, EVENTS_STOPPED),       ///< PDM transfer has finished.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(55): error:  #29: expected an expression
      NRF_PDM_EVENT_END           = offsetof(NRF_PDM_Type, EVENTS_END)            ///< The PDM has written the last sample specified by SAMPLE.MAXCNT (or the last sample after a STOP task has been received) to Data RAM.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(55): error:  #18: expected a ")"
      NRF_PDM_EVENT_END           = offsetof(NRF_PDM_Type, EVENTS_END)            ///< The PDM has written the last sample specified by SAMPLE.MAXCNT (or the last sample after a STOP task has been received) to Data RAM.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(64): error:  #20: identifier "PDM_INTENSET_STARTED_Msk" is undefined
      NRF_PDM_INT_STARTED = PDM_INTENSET_STARTED_Msk,   ///< Interrupt on EVENTS_STARTED event.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(65): error:  #20: identifier "PDM_INTENSET_STOPPED_Msk" is undefined
      NRF_PDM_INT_STOPPED = PDM_INTENSET_STOPPED_Msk,   ///< Interrupt on EVENTS_STOPPED event.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(66): error:  #20: identifier "PDM_INTENSET_END_Msk" is undefined
      NRF_PDM_INT_END     = PDM_INTENSET_END_Msk        ///< Interrupt on EVENTS_END event.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(74): error:  #20: identifier "PDM_PDMCLKCTRL_FREQ_1000K" is undefined
      NRF_PDM_FREQ_1000K = PDM_PDMCLKCTRL_FREQ_1000K,  ///< PDM_CLK = 1.000 MHz.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(75): error:  #20: identifier "PDM_PDMCLKCTRL_FREQ_Default" is undefined
      NRF_PDM_FREQ_1032K = PDM_PDMCLKCTRL_FREQ_Default,  ///< PDM_CLK = 1.032 MHz.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(76): error:  #20: identifier "PDM_PDMCLKCTRL_FREQ_1067K" is undefined
      NRF_PDM_FREQ_1067K = PDM_PDMCLKCTRL_FREQ_1067K   ///< PDM_CLK = 1.067 MHz.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(85): error:  #20: identifier "PDM_MODE_OPERATION_Stereo" is undefined
      NRF_PDM_MODE_STEREO = PDM_MODE_OPERATION_Stereo,  ///< Sample and store one pair (Left + Right) of 16-bit samples per RAM word.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(86): error:  #20: identifier "PDM_MODE_OPERATION_Mono" is undefined
      NRF_PDM_MODE_MONO   = PDM_MODE_OPERATION_Mono     ///< Sample and store two successive Left samples (16 bit each) per RAM word.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(95): error:  #20: identifier "PDM_MODE_EDGE_LeftFalling" is undefined
      NRF_PDM_EDGE_LEFTFALLING = PDM_MODE_EDGE_LeftFalling,  ///< Left (or mono) is sampled on falling edge of PDM_CLK.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(96): error:  #20: identifier "PDM_MODE_EDGE_LeftRising" is undefined
      NRF_PDM_EDGE_LEFTRISING  = PDM_MODE_EDGE_LeftRising    ///< Left (or mono) is sampled on rising edge of PDM_CLK.
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(107): error:  #20: identifier "NRF_PDM" is undefined
      *((volatile uint32_t *)((uint8_t *)NRF_PDM + (uint32_t)pdm_task)) = 0x1UL;
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(120): error:  #20: identifier "NRF_PDM" is undefined
      return (uint32_t)((uint8_t *)NRF_PDM + (uint32_t)pdm_task);
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(133): error:  #20: identifier "NRF_PDM" is undefined
      return (bool)*(volatile uint32_t *)((uint8_t *)NRF_PDM + (uint32_t)pdm_event);
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(144): error:  #20: identifier "NRF_PDM" is undefined
      *((volatile uint32_t *)((uint8_t *)NRF_PDM + (uint32_t)pdm_event)) = 0x0UL;
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(157): error:  #20: identifier "NRF_PDM" is undefined
      return (volatile uint32_t *)((uint8_t *)NRF_PDM + (uint32_t)pdm_event);
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(168): error:  #20: identifier "NRF_PDM" is undefined
      NRF_PDM->INTENSET = pdm_int_mask;
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(182): error:  #20: identifier "NRF_PDM" is undefined
      return (bool)(NRF_PDM->INTENSET & pdm_int_mask);
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(193): error:  #20: identifier "NRF_PDM" is undefined
      NRF_PDM->INTENCLR = pdm_int_mask;
C:\Users\Juzer\AppData\Local\Arm\Packs\NordicSemiconductor\nRF_Drivers\4.0.0-2.alpha\hal\nrf_pdm.h(204): error:  #20: identifier "NRF_PDM" is undefined
      NRF_PDM->ENABLE = (PDM_ENABLE_ENABLE_Enabled << PDM_ENABLE_ENABLE_Pos);
..\..\..\main.c: 0 warnings, 30 errors
".\_build\nrf51422_xxac_s130.axf" - 30 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed:  00:00:01

  • Hi,

    This cannot work, as the nRF51 does not have a PDM peripheral. But if you need a PDM peripheral you should consider the nRF52 instead, or use another microphone interface.

    1) So I have picked uart over BLE example from keil pack installer.

    Though not relevant to the question, I advice against using the Keil pack installer. It is easy to end up with a combination of packs that are incompatible. In general I recommend downloading the full SDK as a zip instead, which has everything integrated. You can find the SDK distributions here. The latest SDK with support for nRF51 is 12.3. 

    2) Then I have included the "nrf_drv_pdm.h" library.

    3) After that I have changed #define PDM_ENABLED  from 0 to 1 in nrf_drv_config.h

    And  after doing all these steps when I run build it is showing around 30 errors in nrf_pdm.h file like used of undeclared identifier 'NRF_PDM'.and many more.

    You can see that all errors are "xxxx is undefined". This is because the compiler does not know about it. Looking at one example, you see that NRF_PDM_Type is only defined in nf52.h and nrf52840.h in SDK 12.3 (I use that as reference as I don't know which version you are using). It is not defined in nrf51.h, and the reason is that the nRF51 does not have a PDM peripheral.

Related