Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparator library cannot invert without outputting to a pin. #115

Closed
SpenceKonde opened this issue Mar 31, 2021 · 7 comments
Closed

Comparator library cannot invert without outputting to a pin. #115

SpenceKonde opened this issue Mar 31, 2021 · 7 comments

Comments

@SpenceKonde
Copy link
Contributor

While porting the comparator library I realized that the invert bit in the mux register is controlled by the output setting! This means that the library cannot be used to produce and event with inverted output unless the output pin is also used. Is there a reason for this seemingly arbitrary limitation? I would think that the invert bit should be controlled by it's own boolean property - and that any inverting specified by the output setting would be implemented separately from inverting the event (by setting INVEN on the corresponding PINnCTRL register (which IMO would be excessive for this library)

@MCUdude
Copy link
Owner

MCUdude commented Apr 8, 2021

Whaaat? So this means that if you use the output of the comparator internally, and don't enable the output, the comparator can't invert its own "internal output"?

Is this documented somewhere (errata) or did you find it by coincidence?

@SpenceKonde
Copy link
Contributor Author

No no, the hardware supports it, but your library doesn't - the invert bit is controlled by the output field, and there's no option for invert without enabling output....

  enum output_t : uint8_t {
    disable = 0x00,
    enable  = 0x40,
    invert  = 0x80,
  }; 

@MCUdude
Copy link
Owner

MCUdude commented Apr 8, 2021

Ah, I see! I'll come up with a solution for this. Another thing I just realized was lacking was a way to read the state of the comparator without reading the physical output pin or triggering off an interrupt.

Comparator.read(); // Read output of comparator, internally

How about re-doing the output_t enum to something like this?

  enum output_t : uint8_t {
    disable = 0x00,
    disable_invert = 0x80,
    enable  = 0x40,
    enable_invert  = 0xC0,
    invert  = 0xC0,
  }; 

BTW It would be nice to have a Zoom meeting with you soon! Perhaps to figure out if there are other libraries that need to be ported or created, further cooperation between cores, hardware/UPDI programmers, etc. Let me know if you have time sometime!

@MCUdude MCUdude closed this as completed in 3f20e21 Apr 8, 2021
@SpenceKonde
Copy link
Contributor Author

Oh yeah, we should do that soon, I think that's a good idea.

I'm still operating on pandemic schedule, so can make almost any time as long as I don't need to leave the house. And my sleep schedule.... basically isn't a schedule.

Oh - definitely check on the boards you m,aintain comparator for whether you even need to set the pin output.. On Dx and tiny, you do not!

@MCUdude
Copy link
Owner

MCUdude commented Apr 9, 2021

Oh yeah, we should do that soon, I think that's a good idea.
I'm still operating on pandemic schedule, so can make almost any time as long as I don't need to leave the house. And my sleep schedule.... basically isn't a schedule.

I'm usually available in the evenings. I know this might be a little too short of a notice, but how about today/tonight, 10pm my time, 4pm your time?

@SpenceKonde
Copy link
Contributor Author

Yeah, that works for me., I would like to catch you up on some of what I'd been working on (and be called out if what I'm doing is foolish :-P )

@MCUdude
Copy link
Owner

MCUdude commented Apr 9, 2021

Excellent, mail me a Zoom link, and I'll see you in ~2.5 hours! I'll write down a few things we'll have to discuss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants