Real time clock + external interrupt in one PIC possible?


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Real time clock + external interrupt in one PIC possible?

    Hi,
    You don't have to use the 40-pin 18F45K22. You can use the 28-pin 18F25K22 with very minor changes to the code (CONFIG) or you can use another PIC - as long as it has a TMR1 & TMR2. But, if you want the code to run as-is then 45K22 it is.

    If the distance per pulse is not 0.6m then you need to change the 39322 constant. For 0.61m it would be 39977 and for 0.59m it would be 38666 so as I think you can see you should be able to calibrate very accuratly. The final result will always suffer from truncation in the math routines so the display can be short as much as one count (0.6m or whatever distance one pulse equals) - which I don't think matters much.

    /Henrik.

  2. #2
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: Real time clock + external interrupt in one PIC possible?

    Hello Henrik,

    I guess I´m blind. In the first program you had RB6 as counter input. In the second program RB6 is the start-stop button. Where did the counter input go?

    regards
    Mugelpower

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Real time clock + external interrupt in one PIC possible?

    On the 18F1320 (for which I tried to write the original program) the T1CKI is on RB6. On the 18F45K22 the T1CKI is on RC0.

    /Henrik.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Real time clock + external interrupt in one PIC possible?

    Did you ever get it running on your end or did you loose interest?

    I'm cleaning up my desk, can I put the dev board away?
    It's best to ask because if I don't Murphy tells me there will be a new question, bug report or feature request tomorrow :-)

    /Henrik.

  5. #5
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: Real time clock + external interrupt in one PIC possible?

    Hello Henrik,
    no I´m not out of interest. I bought some 18F45K22 and 16Mhz crystal generators and then realized my PICKIT2 doesn´t support this device. I really appreciate your help and I´m astonishied about your speed. But I need some more time to get
    into the hardware. I´ll realize that with a 18F1320 because i am already working on a project : a water pump, fuel pump and fan controller. I´m shure the configs for the speedo project will drive me crazy.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Real time clock + external interrupt in one PIC possible?

    If you look at this thread: http://www.microchip.com/forums/m540021.aspx I Think you'll find that you can get your PICKit2 working with the 45K22. If you don't wan't to mess around just get a PICKit3 from Digikey, Mouser or Microchip Direct and be done with it :-)

    The timer code, as written, expects an 8MHz Clock, you'll need to change some things if you're using 16MHz, the CONFIG isn't one of them though. It should run fine with the CONFIG as posted.

    /Henrik.

  7. #7
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: Real time clock + external interrupt in one PIC possible?

    Hello Henrik,

    I´m stupid. Looked at the cristals and they were the right 8 MHz ones. Ordered the PICkit 3 yesterday so i can move along.

Similar Threads

  1. real time clock
    By maria in forum Code Examples
    Replies: 44
    Last Post: - 1st March 2022, 12:13
  2. Real time clock + external interrupt in one PIC possible?
    By Mugelpower in forum mel PIC BASIC
    Replies: 1
    Last Post: - 10th September 2017, 17:11
  3. Real Time Clock
    By in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd June 2012, 04:52
  4. Real time clock
    By PlantBob in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 10th February 2011, 13:01
  5. Real Time Clock
    By savnik in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th December 2006, 02:02

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts