Hello,
We are using NCS v1.9.0 and nRF51820 SoC in our project.
Here is a question about using the COMP function.After I configure and initialize COMP,it returns NRFX_SUCCESS.But when I using function nrfx_comp_start() or nrfx_comp_sample(),the device restarts.I can only find one example of LPCOMP in nRF5 SDK,and I did it like that.Are there any additional steps before configuring COMP?
Below is my code:
CONFIG_NRFX_COMP=y CONFIG_NRFX_PRS=y
static nrfx_comp_config_t comp_conf = NRFX_COMP_DEFAULT_CONFIG(NRF_COMP_INPUT_3);
void comp_triggered(nrf_comp_event_t event)
{
switch (event)
{
case NRF_COMP_EVENT_READY:
printk("comp triggered ready.\r\n");
break;
case NRF_COMP_EVENT_DOWN:
printk("comp triggered down.\r\n");
break;
case NRF_COMP_EVENT_UP:
printk("comp triggered up.\r\n");
break;
case NRF_COMP_EVENT_CROSS:
printk("comp triggered cross.\r\n");
break;
default:
break;
}
}
void battery_monitor_init(void)
{
int ret;
ret = nrfx_comp_init(&comp_conf, comp_triggered);
if (ret != NRFX_SUCCESS)
{
return;
}
nrfx_comp_start(NRFX_COMP_EVT_EN_CROSS_MASK |
NRFX_COMP_EVT_EN_UP_MASK |
NRFX_COMP_EVT_EN_DOWN_MASK |
NRFX_COMP_EVT_EN_READY_MASK,
NRFX_COMP_SHORT_STOP_AFTER_DOWN_EVT);
}
