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

I can not re-program the nrf51822. Why?

I have uploaded the following code, but I can not re-program the next.



#define AREF0						0
#define AIN3						2
#define AIN4						3


int main(void)
	{
// Start 16 MHz crystal oscillator 
  NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
  NRF_CLOCK->TASKS_HFCLKSTART = 1;

  // Wait for the external oscillator to start up 
  while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) 
  {
  }
  
  
NRF_GPIO->PIN_CNF[AREF0] = (GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos) | 
								(GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) | 
								(GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | 
								(GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | 
								(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
	
	
	//nrf_gpio_cfg_output(AREF0);
	nrf_gpio_cfg_output(AIN3);
	nrf_gpio_cfg_output(AIN4);
	
	NRF_GPIOTE->INTENSET=GPIOTE_INTENSET_PORT_Msk;

	flag_TIM0.OVF_10ms=0;


	//GO_SLEEP;
	NRF_POWER->SYSTEMOFF = 1;
	
	
	while(true)
		{

		TogglePin_us(20, AIN3);

		}
	}


Thanks Peter

Related