EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Cannot get comparator to work in PIC16F887

Cannot get comparator to work in PIC16F887

|

Microcontroller › PIC › Cannot get comparator to work in PIC16F887

  • This topic has 2 replies, 2 voices, and was last updated 10 years, 9 months ago by Ashutosh Bhatt.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • August 24, 2014 at 10:57 am #3217
    Erik Nielsen
    Participant
    Hi – I am new in programming PIC device and I have a project where I need to use one of the two Comparators in PIC16F887

    I have read the datasheet several time but is still unsure about setting up the port – hope someone can come with an solution.

    in my project I use tree 7 segment display so I use interrupt to make them work and its works fine.

    I do not know for sure if this gives problem for my comparator!?
     
    (I use Pascal as my sw)
     
    – interrupt setup:

    Procedure interrupt;
    begin
        PORTB := 0;
        PORTD := ciffer[v] + blink_on;
        PORTB := zz; // turn on appropriate 7seg. display
        v := v + 1;
        zz := zz shr 1;
        if zz = 16 then zz := 128; // 4 // prepare mask for digit
        if v > 2 then v := 0; // 3 disp. // turn on 1st, turn off 2nd 7seg.
        TMR0 := 0;
        INTCON := $20;
    end;

    and my setup for the comparator:

    ANSELH := 0;
    // setup Port A :
    TRISA :=%11011111; // input execp bit A5 – used for output for comparator
    ANSEL :=%00001001; // bit A0 and A3 analog = input for comparator
    CM1CON0 :=%11100000; // Comparator C1 enabled
    SRCON :=%00000000; // no latch enabled
    VRCON :=%00100000; // no v ref. enabled

    this is the correct setting for comparator as best I know – but not sure because it not work.

    here is the code where I retrieve the output 

    If portA.5=1 then …

    Can any help ? – do I need to do something for getting the the output

    Best regards Erik Nielsen, Denmark.
     
    August 24, 2014 at 3:38 pm #12068
    Erik Nielsen
    Participant
    1. Just want to tell you that I get it to work now !

      – there was nothing wrong in my code but the PIC I used was damaged – when trying a

      new pic all works fine – thanks again

      Regrads Erik

     

    August 25, 2014 at 6:58 am #12069
    Ashutosh Bhatt
    Participant

    for learning PIC you can follow tutorials on

    EG Labs / micro controller / PIC

     

    All the best

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Can I make two inputs from one?? June 17, 2025
  • Photo interrupter Connections June 17, 2025
  • Is AI making embedded software developers more productive? June 17, 2025
  • Why can't I breadboard this oscillator? June 17, 2025
  • Cataract Lens Options? June 16, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise