|
|
View previous topic :: View next topic |
Author |
Message |
Peter Guest
|
PIC16F688 and comparator outputs + internal VCRef. |
Posted: Sat Sep 15, 2007 7:29 pm |
|
|
Hi all,
1. Am just wondering whether there is any way to redirect the output of comparator(s) to pins while using VCRef at the same time as one of inputs. I mean according to the data sheet:
- CM<2> = 110 allows redirect outputs to pins
- CM<2> = 010 lets use VCRef
So are these options mutually excluding? It looks so ... I could use interrupt, and a piece of code to output this whenever I want, but this is out of the question.
2. By the way, how these 24bit definitions like A0_A1 0x3ff02 correspond to the content of 8 bit CM register? Am curious whether this all goes just to CM after being binary rearranged, or somewhere else ... ?
Cheers,
Peter. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 16, 2007 1:33 am |
|
|
Quote: |
just wondering whether there is any way to redirect the output of
comparator(s) to pins while using VCRef at the same time as one of
inputs.
|
I don't think you can do that. There isn't a mode option for it. One
possible work-around would be to use the comparator interrupt.
Inside the INT_COMP isr, read the CMCON0 register and output the
value of C1OUT and C2OUT to two i/o pins of your choice. Due to the
interrupt overhead, there would be some latency in updating the i/o pins.
There would be a frequency limit on the rate that the pins could be
updated. But it might be acceptable, depending on your application.
Quote: |
how do these 24bit definitions like A0_A1 0x3ff02 correspond to the
content of 8 bit CM register |
You can find out. Make a test program where you call the
setup_comparator() function several times, and put in a different constant
from the 16F688.H file each time. Then look at the .LST file, and also
at the register addresses in the data sheet. Note what byte values are
being put into each register. Also look for their use as bitmasks in AND
and OR operations. |
|
|
Guest
|
|
Posted: Sun Sep 16, 2007 6:42 am |
|
|
PCM programmer wrote: |
I don't think you can do that. There isn't a mode option for it. One
possible work-around would be to use the comparator interrupt. |
That's out of question. Too high freq. This was going to be a LED brightness regulator based on current sensing and comparing + charging capacitance. There are other operations in the system that cannot be interfered with often interrupts anyway. I guess I'll change the chip and will go for a PWM in this case (I use all timers of PIC16F688 for different purposes).
Thanks. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|