|
static void ble_stack_init(void)
{
// Initialize SoftDevice.
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
// Subscribe for BLE events.
uint32_t err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
APP_ERROR_CHECK(err_code);
}
void get_temperature(void)
{
NRF_TEMP->TASKS_START = 1; /**¿aê¼Î¶è2aá¿. */
/* Busy wait while temperature measurement is not finished, you can skip waiting if you enable interrupt for DATARDY event and read the result in the interrupt. */
/*lint -e{845} // A zero has been given as right argument to operator '|'" */
while (NRF_TEMP->EVENTS_DATARDY == 0)
{
// Do nothing.
}
NRF_TEMP->EVENTS_DATARDY = 0;
/**@note Workaround for PAN_028 rev2.0A anomaly 29 - TEMP: Stop task clears the TEMP register. */
temperature = (nrf_temp_read()/4);
temperature=temperature*0.6904-0.74;
/**@note Workaround for PAN_028 rev2.0A anomaly 30 - TEMP: Temp module analog front end does not power down when DATARDY event occurs. */
NRF_TEMP->TASKS_STOP = 1; /** Stop the temperature measurement. */
log_printf("temperature = %d\n", temperature);
}
int main(void)
{
nrf_temp_init();
get_temperature();
ble_stack_init();//D-òéÕ»3õê¼»ˉ
}
问题:
在main 函数里面,如果temp初始化和读取在 ble_stack_init() 前面的话,读取是成功的,在 ble_stack_init() 后面的话,就报硬件错误。
在 ble_stack_init()后面, 连 nrf_temp_init() 都会错,这是怎么回事
|
|