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

S130 2.0.0-7 Alpha not enabling internaly used peripherals

Hi

I've updated our platform to using the S130 2.0.0-7 Alpha (Update1). It turned out, that the initialization in out application failed, because erasing a flash page never triggered a NRF_EVT_FLASH_OPERATION_SUCCESS event.

I did a lot of tests and finally was able to find the problem source. In our code we disable all peripherals at startup. Later the used peripherals are enabled by the dedicated modules. It turned out, that disabling TIMER0 is a problem for the S130 2.0.0-7, because it doesn't enable the timer itself.

The following code snippet shows a test sequence. If the line where the TIMER0 gets disabled is active the end of the code is never reached. If not it works like a charm.

/************************************************************************************/
int main(void)
{

	uint32_t error_code;
	uint32_t event_id;
	bool success_b = false;
	
/*-- Code Statements ---------------------------------------------------------------*/
	
	// disable TIMER0 before enabling the softdevice
	NRF_TIMER0->POWER = 0;

  // init softdevice
  sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, softdevice_assertion_handler_f);
	
  // erase to flash
	error_code = sd_flash_page_erase(0x3A000 / 1024);
	if (error_code != NRF_SUCCESS)
	{
		return (false);
	}
	
  // wait for the NRF_EVT_FLASH_OPERATION_SUCCESS in busy loop
  while (!success_b)
  {
		if (sd_evt_get(&event_id) != NRF_ERROR_NOT_FOUND)
		{
			if (event_id == NRF_EVT_FLASH_OPERATION_SUCCESS)
			{
				// SUCCESS
				success_b = true;
				break;
			}
	  }
	}
	
	// code never reached when TIMER0 is powered down at startup
	while (1)
	{
	}
	
}/* main */
/************************************************************************************/

It's not a problem now as I know the issue. A fix in the upcoming softdevice S130 2.x would be great anyway.

Regards Adrian

Parents
  • The POWER register of NRF_TIMER0 is not documented and should not be written to by the application. I believe it's appearance in the header file is a mistake.

    I guess you can use the SHUTDOWN task if you don't intend to use the timer yourself.

  • You can use the SHUTDOWN task for revision 2 and 3. For revision 1, I'm not sure, if that is of interest let me know and I'll find out. Be aware that there is a PAN for using the SHUTDOWN task with PPI on revision 2. The SHUTDOWN task resets the peripheral and it will be in the lowest power mode. It will release the need for HFCLK and because of this startup time may be longer compared to starting the timer from the stopped state. The POWER register shouldn't be used, so I guess that is why it isn't checked or used by the SoftDevice.

Reply
  • You can use the SHUTDOWN task for revision 2 and 3. For revision 1, I'm not sure, if that is of interest let me know and I'll find out. Be aware that there is a PAN for using the SHUTDOWN task with PPI on revision 2. The SHUTDOWN task resets the peripheral and it will be in the lowest power mode. It will release the need for HFCLK and because of this startup time may be longer compared to starting the timer from the stopped state. The POWER register shouldn't be used, so I guess that is why it isn't checked or used by the SoftDevice.

Children
No Data
Related