Hi. I'm using nRF51822, SDK10.0.0, S130. I made "radio test" program as below at the first.
void radio_tx_carrier_test(unsigned char freq_ch) {
NRF_RNG->TASKS_START = 1;
// 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)
{
// Do nothing.
}
NRF_RADIO->SHORTS = 0;
NRF_RADIO->EVENTS_DISABLED = 0;
NRF_RADIO->TEST = 0;
NRF_RADIO->TASKS_DISABLE = 1;
while (NRF_RADIO->EVENTS_DISABLED == 0)
{
// Do nothing.
}
NRF_RADIO->EVENTS_DISABLED = 0;
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk;
NRF_RADIO->TXPOWER = (4 << RADIO_TXPOWER_TXPOWER_Pos);
NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_2Mbit << RADIO_MODE_MODE_Pos);
if(freq_ch==0) NRF_RADIO->FREQUENCY = 0;
else if(freq_ch==1) NRF_RADIO->FREQUENCY = 45;
else if(freq_ch==2) NRF_RADIO->FREQUENCY = 83;
NRF_RADIO->TEST = (RADIO_TEST_CONSTCARRIER_Enabled << RADIO_TEST_CONSTCARRIER_Pos) \
| (RADIO_TEST_PLLLOCK_Enabled << RADIO_TEST_PLLLOCK_Pos);
NRF_RADIO->TASKS_TXEN = 1;
NRF_POWER->DCDCEN = 1;
}
int main(void) {
radio_tx_carrier_test(1);
while(1)
{
__WFI();
;
}
}
Yes. it works well.
So I decided to add this program to my application code as below.
static void gpio_init(void) {
ret_code_t err_code;
nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
in_config.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(0, &in_config, in_pin_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(0, true);
}
int main(void) {
uint32_t err_code;
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
ble_stack_init();
......
gpio_init();
......
nrf_drv_gpiote_in_uninit(0);
nrf_drv_gpiote_in_event_disable(0);
nrf_gpio_cfg_output(0);
nrf_gpio_pin_clear(0);
nrf_delay_ms(300);
err_code = softdevice_handler_sd_disable();
APP_ERROR_CHECK(err_code);
nrf_delay_ms(300);
radio_tx_carrier_test(1);
while(1)
{
__WFI();
;
}
}
But "radio_tx_carrier_test" function doesn't work. If I remove gpio_init(); function, it works well. But i add gpio_init function, it doesn't work, even though i made it disabled as you can see. How can i do for this?
I need your help.