#problem Not work ble sample code with s130 softdevice on nrf51822 module.
I just want to advertise by sample code.LED test with s130 is work well.
#Environment
- target:nrf51822_CEAA(in BVMCN5112-CEAA module)
- SDK:nRF5SDK_12.3.0_d7731ad
- DebugAdapter:ST-Link-v2(SWD)
- Debugger:Open-OCD 0.10.0 BTreceive
- software :nRFconnnect(ASUS_Z00AD android5.0)
- base src:ble_app_template
- Tool chain: GNU tools ARM Embedded 5.4 2016q3
- GNU_VERSION := 5.4.2
- GNU_PREFIX := arm-none-eabi
LED test work good and loop endless.
"main() at main.c"
#include "nrf_delay.h"
#define OUTPIN PIN02
int main(void)
{
//must be input_mode some pin in this BVMCN5112 module.
int list_must_be_set_input[] = LIST_INPUT_MODE;//#Defined in "my_custom_board.h"
for (int i = 0;i<NUM_INPUT_MODE;i++){
nrf_gpio_cfg_input(list_must_be_set_input[i],NRF_GPIO_PIN_NOPULL);
}
nrf_gpio_cfg_output(OUTPIN);
nrf_gpio_pin_clear(OUTPIN);
//LED test. this test is work well.
/*for(int cnt = 0;cnt<10;cnt++)
{
nrf_gpio_pin_write(OUTPIN,1);
//nrf_gpio_pin_toggle(PIN01);
nrf_delay_ms(250*cnt);
nrf_gpio_pin_write(OUTPIN,0);
nrf_delay_ms(250*cnt);
}*/
uint32_t err_code;
bool erase_bonds;
// Initialize.
err_code = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(err_code);
timers_init();
buttons_leds_init(&erase_bonds);
ble_stack_init();
peer_manager_init(erase_bonds);
if (erase_bonds == true)
{
NRF_LOG_INFO("Bonds erased!\r\n");
}
gap_params_init();
advertising_init();
services_init();
conn_params_init();
// Start execution.
NRF_LOG_INFO("Template started\r\n");
application_timers_start();
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
////// To check error by LED. Runnning always ON (= NOT NRF_SUCCESS).
if(err_code != NRF_SUCCESS){
nrf_gpio_pin_write(OUTPIN,1);
}**
APP_ERROR_CHECK(err_code);
// Enter main loop.
for (;;)
{
if (NRF_LOG_PROCESS() == false)
{
power_manage();
}
}
}
Of cource I wrote S130 softdevice to flash. In debugger console I do this.
>telnet localhost 4444
>reset halt
> flash write_image s130.hex
> flash write_image nrf51822_xxaa.hex
using fast async flash loader. This is currently supported
…
xPSR: 0x61000000 pc: 0x2000001e msp: 0x000007c0
wrote 43676 bytes from file nrf51822_xxaa.hex in 2.203775s (19.354 KiB/s)
> halt
target halted due to debug-request, current mode: Handler SVCall
xPSR: 0x6100000b pc: 0x00009f40 msp: 0x20003f10
when LED testing, in halting handler is "Thread"."SVCall" tell me some wrong work?
I think linker file is wrong, I try some RAM address but not work well. this is address setting I tried.
/*MEMORY
{
FLASH (rx) : ORIGIN = 0x0001b000, LENGTH = 0x40000
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x01000
}*/
/*MEMORY
{
FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000
RAM (rwx) : ORIGIN = 0x20001fe8, LENGTH = 0x2000
}*/
/*copy from nrf51_xxaa.ld */
MEMORY
/*{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000
}*/
How do I decide APP_RAM_BASE address and RAM size? In S130 SDS(infocenter.nordicsemi.com/.../S130_SDS_v2.0.pdf),
APP_RAM_BASE address = 0x20000000+SoftDevice RAM consumption
but I dont know how calc RAM consumption, so I wrote linker file lazy.
Please give me some help. Why dont work only bluetooth? Please some Idea to solve this... Thanks reading.
#2017-07-10 SOLVED I got advise from professional of nrf device, as a result, I added under code on top of main loop, then it works well !
NRF_CLOCK->XTALFREQ = CLOCK_XTALFREQ_XTALFREQ_32MHz;
and this is clock settings in "[board].h".
// Low frequency clock source to be used by the SoftDevice
#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_RC, \
.rc_ctiv = 16, \
.rc_temp_ctiv = 2, \
.xtal_accuracy = 0}
I missunderstood High Freq. source of my device. The device has external 32MHz crystal, sorry.
Thanks all.