SXB Comparitor Function (resolved)
RS_Jim
Posts: 1,768
I seem to be struggling to get the comparitor function to work.· I am feeding pin B2 with a pulse that varies from 1.8 to 2.3 volts and feeding pin one with a voltage divider that gives me aproximately 2.1 volts.· I initialize the SX as follows:
·CMP· Con $08
·CmpEN $00
·Mode CMP
·Mov· !RB,CmpEn
I connect B6 to B0 with a resister and then monitor B6 in an interupt service routine. Do I have to continue issuing the Mode and Mov !RB instructions or is once enough?· I am not getting the pulse to come through even though I can feed the same pulses through a 741 OP am and get it to work as a comparitor. I need to use the compare function to eliminate some noise on the incoming pulse that is causing false triggering in the software.
Thanks
JIm
Post Edited (Radio Shack Jim) : 12/4/2009 12:30:44 PM GMT
·CMP· Con $08
·CmpEN $00
·Mode CMP
·Mov· !RB,CmpEn
I connect B6 to B0 with a resister and then monitor B6 in an interupt service routine. Do I have to continue issuing the Mode and Mov !RB instructions or is once enough?· I am not getting the pulse to come through even though I can feed the same pulses through a 741 OP am and get it to work as a comparitor. I need to use the compare function to eliminate some noise on the incoming pulse that is causing false triggering in the software.
Thanks
JIm
Post Edited (Radio Shack Jim) : 12/4/2009 12:30:44 PM GMT
Comments
You only have to setup the mode once. But be aware that it is a SWAP and not a write.
I think you also have to make RB.0 an output. It's been a long time since I used the comparitor.
Can you post you code ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1st rule of finance...Don't lose money.
Never be ashamed of making an honest·profit.
Live within your means...Make do, or do without.
·
so I configure the comparator with mode $8, then Mov !rb,0 then set rb.0 as input, or just read the state of rb.0?
Thanks for all the help.· I went back and studied the hardware on the chip and found that even if the port is configured as an output, you can read its state.· I found my biggest problem was with my reference voltage.· I used a 10K pot and adjusted it until I got the state change to occur at the right time. Now, I may even try to use edge triggering which I had tried before and found it failed.
RS_JIM