Using built in comparators on the dsPCI33EP

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Using built in comparators on the dsPCI33EP

Post by Lord Grezington »

Hello All

I am building a new circuit and needed to use 3 comparators. I have noticed that the dsPIC33EP32MC204 already has a few of these and I have a few pins spare "brilliant"...

But I have no idea where I start so I can use them. I am assuming to start I need to get the pins right, so:

Comparator 1 - PIN24 negetive input, Pin, PIN23 positive input, The output is stated as C1OUT however there is no pin allocated to this. Does this mean an can store the output as a variable? Or alternatively there is a OA1OUT which I assume is just an analogue output from the Opamp. Ideally I just need this as a variable, if its possible to use it as a variable, how di I do this? Otherwise if I use the OA1OUT can I leave this floating or I need to feed it into another pin?

I need the same reference voltage (-ve input) for all three comparators, is it possible to perhaps use 1 pin as a physical connection to say comparator 1, and then virtually link it to comarator 2 & 3 to save IO pins?

Thanks...

Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Re: Using built in comparators on the dsPCI33EP

Post by Lord Grezington »

Can anyone help with this? I need to try finish this off today if possible...

Thanks

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Using built in comparators on the dsPCI33EP

Post by Benj »

Hello,

Comparators are not something we currently support, purely because there are so many different devices with completely incompatible comparator setups. Have you read through section 25 of the device datasheet and also the additional in depth resource for comparators.

Device datasheet - http://ww1.microchip.com/downloads/en/D ... 00657H.pdf
Comparator dsPIC33EP - http://ww1.microchip.com/downloads/en/D ... 00357e.pdf

Hopefully reading through should give you a flavour of what is possible. Often looking at the bits in the registers and trying to figure out what they specifically do helps a lot. If you need any help reading or writing the registers in Flowcode then let us know.

Usually it's just a case of using a C code icon and referring to the register in block capitals. For example....

CMSTAT = 0x0000; //Write Example
FCV_VAR = CMSTAT; //Read Example

Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Re: Using built in comparators on the dsPCI33EP

Post by Lord Grezington »

Ok, thanks Ben...

Post Reply