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

Crystal initialization problem

I'm experimenting problems with a nRF51822 custom board. Recently I managed to run the blinky sample project. Now I'm trying to test a BLE project, but I'm having problems with my external crystal. I have the 16MHz and the 32KHz crystals (There are details of the board on a previous post here).

I was starting the 32KHz crystal with this code

NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRCCOPY_SRC_Xtal << CLOCK_LFCLKSRCCOPY_SRC_Pos);
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;
while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);

In the checking while the program get stuck. I thought that I had problems with the crystal itself, so I tried to use the 16MHz instead, with the same result.

NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;	
while (!NRF_CLOCK->EVENTS_HFCLKSTARTED);

Then I tried just to simulate (By the way, I'm using Keil 5) and I was surprise to see that the code stop at the same place. I noticed that the simulation is giving constantly the following error:

*** error 65: access violation at 0x40000100 : no 'read' permission

So, if I understand well, I'm having problems to read the status of the NRF_CLOCK. What I'm doing bad? I'm missing something?

Some more information:

  1. I'm not using the softdevice.
  2. It's possible, that the board has some mistakes. It's hand made.
  3. I don't have a lot of experience with microprocessors

Thank you for your time. I'm really stuck here, don't know how to fix this.

Parents
  • An actualization. I tried to force the code, and just go ahead changing the 32kHz crystal start like this

    NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRCCOPY_SRC_Xtal << CLOCK_LFCLKSRCCOPY_SRC_Pos);
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 1;
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
    

    Anyway, the code get stucks in the line while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);. It is supposed to read (or write) to the address 0x40000000 (the NRF address). But the memory at 0x40000000 and after shows complete empty (only 00). I was expecting to see the peripheral data at 0x400xx000 but The debugger show only 00. I'm really very stuck here. Please help.

Reply
  • An actualization. I tried to force the code, and just go ahead changing the 32kHz crystal start like this

    NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRCCOPY_SRC_Xtal << CLOCK_LFCLKSRCCOPY_SRC_Pos);
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 1;
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
    

    Anyway, the code get stucks in the line while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);. It is supposed to read (or write) to the address 0x40000000 (the NRF address). But the memory at 0x40000000 and after shows complete empty (only 00). I was expecting to see the peripheral data at 0x400xx000 but The debugger show only 00. I'm really very stuck here. Please help.

Children
No Data
Related