This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Comparator External Connections

I am attempting to use the COMP section to build a relaxation oscillator. There appear to be a number of interactions between sections, some of which are subtly documented and some for which I find no documentation. For instance, the inability to set a GPIO output once a task is connected to a pin is documented but well-hidden. The fact that enabling a pin as a comparator input completely disables both digital inputs and digital outputs is not documented anywhere that I can find.

Bottom line is that I have everything working nicely as it should, except that the comparator sometimes appears to miss a transition and thereafter is hung. I fundamentally just need to be able to place the comparator output on a digital output pin, but the only way I can find to do that is via the crossing events from the comparator, feeding set and clr tasks of GPIOTE. This causes the same sort of problems as the early IBM PCs using edge-triggered interrupts: If you miss one, you're dead forever. Is there a better way to get the comparator output to appear on a pin? If not, how best can I initialize things to ensure that I don't miss a transition?

Parents
  • HI Steve,

    Bottom line is that I have everything working nicely as it should, except that the comparator sometimes appears to miss a transition and thereafter is hung. I fundamentally just need to be able to place the comparator output on a digital output pin

    Could you elaborate on what you mean by the comparator missing a transition? In my mind If the comparator misses a transition, then the output from the comparator would be unchanged so it would not help to output the comp output to a GPIO. 

    Best regards

    Bjørn

Reply
  • HI Steve,

    Bottom line is that I have everything working nicely as it should, except that the comparator sometimes appears to miss a transition and thereafter is hung. I fundamentally just need to be able to place the comparator output on a digital output pin

    Could you elaborate on what you mean by the comparator missing a transition? In my mind If the comparator misses a transition, then the output from the comparator would be unchanged so it would not help to output the comp output to a GPIO. 

    Best regards

    Bjørn

Children
  • In essence I'm building a relaxation oscillator using the comparator. In my initial reading of the datasheet I missed the fact that it's apparently not possible to directly place the comparator output on an I/O pin, so I fell back to using the event / task / PPI mechanism. The transition event trips a task to flip the state of a GPIO pin. I a transition is ever missed, the output doesn't change state, and the oscillator therefore stops forever.

    Fundamentally all I need is to be able to place the comparator output directly on an I/O pin. I know I could have firmware read the RESULT register and set a pin, but that's not feasible in my application. I have a stopgap solution whereby the firmware checks to see if the oscillator has stopped and gives it a kick start, but that's pretty messy and really not a good solution.

  • Yes, but my question was if there is a valid transition on the Comparator pin or not? IF there isnt, then is this transition is not detected by the comparator? If that is the case then outputing the comp output to a GPIO will not solve the problem. Or to you mean that the Comparator correctly detects the transition, but does not generate the transition event?

    As far as I know there is no other way than using PPI and GPIOTE to output the Comparator output on a GPIO. 

Related