This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

COMP to GPIOTE at ~250KHz, Value Sync or GPIOTE Failure

Hi,

Just after an eyes over. I'm using the internal COMP to save on an external chip and wiring the output out to a GPIOTE. What occurs is the NRF_COMP->EVENTS_DOWN fires, which clears the channel/pin, however the NRF_COMP->EVENTS_UP does not appear to be firing, or GPIOTE is ignoring.

I'm using minimal hysteresis (61 and 62 out of 63) and the signal may be quite fast, 250KHz. I wonder if there's a frequency limit to the GPIO or PPI (apparently COMP can handle it).

Cheers,

Andrew


  NRF_COMP->PSEL = CFG_AIN_POWERMANAGER_UVLO << COMP_PSEL_PSEL_Pos;
  NRF_COMP->MODE = COMP_MODE_SP_High << COMP_MODE_SP_Pos;
  NRF_COMP->REFSEL = COMP_REFSEL_REFSEL_Int2V4 << COMP_REFSEL_REFSEL_Pos;
  NRF_COMP->TH = UVLO_THUP << COMP_TH_THUP_Pos | UVLO_THDOWN << COMP_TH_THDOWN_Pos;
  NRF_COMP->SHORTS = COMP_SHORTS_READY_SAMPLE_Enabled << COMP_SHORTS_READY_SAMPLE_Pos;

  NRF_PPI->CH[CFG_PPI_POWERMANAGER_CHANNEL_UVLO_ABOVE].EEP = (uint32_t) &NRF_COMP->EVENTS_UP;
  NRF_PPI->CH[CFG_PPI_POWERMANAGER_CHANNEL_UVLO_ABOVE].TEP = (uint32_t) &NRF_GPIOTE->TASKS_SET[CFG_GPIOTE_POWERMANAGER_CHANNEL_UVLO];
  NRF_PPI->FORK[CFG_PPI_POWERMANAGER_CHANNEL_UVLO_ABOVE].TEP = (uint32_t) &NRF_COMP->TASKS_SAMPLE;
  NRF_PPI->CHENSET = 1 << CFG_PPI_POWERMANAGER_CHANNEL_UVLO_ABOVE;

  NRF_PPI->CH[CFG_PPI_POWERMANAGER_CHANNEL_UVLO_BELOW].EEP = (uint32_t) &NRF_COMP->EVENTS_DOWN;
  NRF_PPI->CH[CFG_PPI_POWERMANAGER_CHANNEL_UVLO_BELOW].TEP = (uint32_t) &NRF_GPIOTE->TASKS_CLR[CFG_GPIOTE_POWERMANAGER_CHANNEL_UVLO];
  NRF_PPI->FORK[CFG_PPI_POWERMANAGER_CHANNEL_UVLO_BELOW].TEP = (uint32_t) &NRF_COMP->TASKS_SAMPLE;
  NRF_PPI->CHENSET = 1 << CFG_PPI_POWERMANAGER_CHANNEL_UVLO_BELOW;

  NRF_GPIOTE->CONFIG[CFG_GPIOTE_POWERMANAGER_CHANNEL_UVLO] = GPIOTE_CONFIG_OUTINIT_High << GPIOTE_CONFIG_OUTINIT_Pos | GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos | CFG_PIN_POWERMANAGER_UVLO_OUT << GPIOTE_CONFIG_PSEL_Pos;

  • Sorry I should have mentioned the COMP is started outside of this routine. The value at the pin is reported back by a PIC16 over SPI and out to BLE where it can be viewed in an App, but I can also see the effect in hardware as it causes an auto shutdown in one of the PIC16's peripherals. 

    NRF_COMP->ENABLE = COMP_ENABLE_ENABLE_Enabled << COMP_ENABLE_ENABLE_Pos;
    NRF_COMP->TASKS_START = 1;


    Other variables are:

    #define pinDisconnectInputBuffer (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
    #define CFG_GPIOTE_POWERMANAGER_CHANNEL_UVLO 0
    #define CFG_PIN_POWERMANAGER_UVLO_IN 2
    #define CFG_AIN_POWERMANAGER_UVLO COMP_PSEL_PSEL_AnalogInput0


  • Hi,

    GPIO and PPI should be able to handle at least 8 MHz.

    Have you tested the code in a standalone application, to make sure nothing else in your application overlaps with the used resources?

    Have you checked with a debugger that the registers are set to the correct values after all initialization in the application is done?

    What is the values of CFG_PPI_POWERMANAGER_CHANNEL_UVLO_ABOVE and CFG_PPI_POWERMANAGER_CHANNEL_UVLO_BELOW?

    Best regards,
    Jørgen

  • It is a standalone, there's 100% no conflict with these resources.

    I can test the registers are later today but I'm confident they are. The comparator is sampling correctly on the fork on the PPI is running the comp sample and I can see the value switch. The GPIOTE is clearing the pin, it just doesn't want to set again. Does the input buffer have to be enabled for some reason?

    #define CFG_PPI_POWERMANAGER_CHANNEL_UVLO_ABOVE 4
    #define CFG_PPI_POWERMANAGER_CHANNEL_UVLO_BELOW 5




  • Hi,

    Did you resolve this issue, or do you still need help with it?

    If it is not resolved, please provide the register readouts as requested before.

    Best regards,
    Jørgen

  • Hi Jorgen,

    The project no longer interfaces with the PIC16 so this method doesn't need to occur. I assume it's a valid problem though, can't see otherwise.

    Regards,

    Andrew

Related