RTC - code not working - Mel's example


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Malc I brought one of those for my easy-pic spent hours and over severals day's thinking it was my code. Which I knew it did work in another project, At the time I was unsure about the code but when I loaded the hex file into my running project everything worked ok. so this led me to the RTC moudle (the one shown in the picture), So I built the curcuit on vero board and that worked percfet, There was one connection I never used, So in the end atfer waisting days hunting I just threw it in the bin and could not be botherd to send it back. I did look at but not found nothing

    Have you tried your own simple circuit ?
    Last edited by chuck; - 23rd March 2010 at 22:35.

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the reply Chuck,

    To be honest I've not tried breadboarding the chip like you suggest. I'll try that tomorrow and see if it makes any difference. Are you suggesting that there is a flaw with the EasyPIC5 board or just the RTC2 board... If the latter, why does it seem to work with other examples that write once to the module and then read the time back from that point... IMO it seems as if the code is doing strange things. I noticed that if I press the increment button it doesn't decrease by one unit, it seems to jump. Maybe the value on the LCD isn't the actual value that the counter is. EG, the hour displayed on the LCD hasn't refreshed to show the value the code has been set to by the button..

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Malc,

    In the modified version of Melanie's code, you have ...

    Code:
    IncButton var PORTA.6	' Press to Increment Button
    The 16F877A doesn't have a PORTA.6, and to the program it probably looks like the button is always pressed.
    <br>
    DT

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    How did I miss that ! (embarrassed smile goes here !)

    I'll re-compile tonight after work and see what happens

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Well must be something with the configuration of port A.

    Code:
    	DecButton var PORTD.0	' Press to Decrement Button
    	SetButton var PORTD.1  'Press to Set/memorise Button
    	IncButton var PORTD.2	' Press to Increment Button
    The above works ! as does

    Code:
    	DecButton var PORTE.0	' Press to Decrement Button
    	SetButton var PORTE.1  'Press to Set/memorise Button
    	IncButton var PORTE.2	' Press to Increment Button
    Thanks to all those who posted... at least I've proved my hardware is ok, just need to learn how to set up these devices correctly !

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    Well must be something with the configuration of port A.
    PORTA ... well, you have ...

    ADCON1 = $0F

    For a 16F877A it should be ...

    ADCON1 = 7

    Unless you want some analog channels.
    <br>
    DT

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    PORTA ... well, you have ...

    ADCON1 = $0F

    For a 16F877A it should be ...

    ADCON1 = 7

    Unless you want some analog channels.
    <br>
    I tried that well, ADCON1 = $0F but that didn't work... but then I'm currently using an 16f877a

  8. #8
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post

    For a 16F877A it should be ...

    ADCON1 = 7

    Unless you want some analog channels.
    <br>
    Uhmmm.. tried that and then changed the code to

    Code:
    	DecButton var PORTA.0	' Press to Decrement Button
    	SetButton var PORTA.1  'Press to Set/memorise Button
    	IncButton var PORTA.2	' Press to Increment Button
    but that still left the 12/24 hr set mode over-writing each other again !

  9. #9
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Try using DT's "AllDigital.inc"

    Quote Originally Posted by Darrel Taylor View Post

    Unless you want some analog channels.
    <br>
    Malc-C, since it doesn't appear you are using any analog channels in your application I recommend you use DT's "AllDigital.inc" routine as an INCLUDE in your program. It works great and takes care of all the register settings you are trying to figure out so that you don't have a conflict of your digital processing with ports that are set for analog input.

  10. #10
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    I'm looking at using the code to set a photo period, ie at a set time, say 11:00 pm lights go off, then at 06:00 am lights come on.

    Is it a simple case of : (not actual code, more logic)

    Code:
    set off time
    set on time
    
    I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCYear,RTCCtrl]
    
    If RTCHour=>off time or <=on time then lights off
    Else lights on

Members who have read this thread : 0

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