16f877A and shiftin shiftout


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Default 16f877A and shiftin shiftout

    I have a program that uses shiftin and shiftout to read and set the time on a ds1302. It works on the 16f876A, but when I move it to the 877A, it no longer reliably reads the ds1302.

    I also have some lcdout commands that also get flaky in the transition.

    any suggestions?

    thanks

    bob

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ghdsfier8 View Post
    I have a program that uses shiftin and shiftout to read and set the time on a ds1302. It works on the 16f876A, but when I move it to the 877A, it no longer reliably reads the ds1302.
    I also have some lcdout commands that also get flaky in the transition.
    any suggestions?
    thanks
    bob
    Change the kitty litter in the fuel tank?
    How 'bout some code...

  3. #3
    Join Date
    Feb 2008
    Posts
    2


    Did you find this post helpful? Yes | No

    Default 16f877a code

    skimask,

    thanks for the suggestion but i just changed the kitty litter last month. here's the code

    DEFINE LOADER_USED 1
    ADCON1 = 15
    CMCON=7
    'DEFINE OSC 20

    '-------------------Pin assignments
    ' for Hardware interface with ds1302 and dealing with time
    clk_pin_ds1302 var portb.1
    data_pin_ds1302 var portb.2
    rtccs_pin_ds1302 var portb.4
    seconds_subscript CON 2
    minutes_subscript CON 1
    hours_subscript CON 0
    low rtccs_pin_ds1302
    low clk_pin_ds1302
    trisb=0
    trisa=0
    'Define RTC Command Constants
    regsec CON %00000
    regmin CON %00001
    reghrs CON %00010
    regctrl CON %00111
    seconds_sent var byte
    minutes_sent var byte
    hours_sent var byte
    time VAR Byte(3)
    byteone VAR Byte
    bytetwo VAR Byte
    nibblefive VAR byte
    CR con 13
    lsbpre con 1
    lsbfirst con 0
    ' ====================== MAIN PROGRAM LOOP ==========================

    main:
    GOSUB readthetime
    hserout [" time: ",DEC2 time(0),":",DEC2 time(1), ":", DEC2 time(2),cr]
    PAUSE 100
    GOTO main

    ' --------------------------------START SUBROUTINES------------------------------------------------------
    Readhr:
    HIGH rtccs_pin_ds1302
    SHIFTOUT data_pin_ds1302, clk_pin_ds1302, LSBFIRST, [%1\1,reghrs\5,%10\2]
    SHIFTIN data_pin_ds1302, clk_pin_ds1302, LSBPRE, [time(hours_subscript)]
    LOW rtccs_pin_ds1302
    time(hours_subscript) = 10*((time(hours_subscript)<<11) >> 15) + ((time(hours_subscript)<<12)>>12)
    RETURN

    Readmin:
    HIGH rtccs_pin_ds1302
    SHIFTOUT data_pin_ds1302, clk_pin_ds1302, LSBFIRST, [%1\1,regmin\5,%10\2]
    SHIFTIN data_pin_ds1302, clk_pin_ds1302, LSBPRE, [time(minutes_subscript)]
    min00:
    LOW rtccs_pin_ds1302
    byteone = 10*((time(minutes_subscript)<<8) >> 12)
    bytetwo = ((time(minutes_subscript)<<12)>>12)
    time(minutes_subscript) = byteone + bytetwo
    RETURN

    Readsec:
    HIGH rtccs_pin_ds1302
    SHIFTOUT data_pin_ds1302, clk_pin_ds1302, LSBFIRST, [%1\1,regsec\5,%10\2]
    SHIFTIN data_pin_ds1302, clk_pin_ds1302, LSBPRE, [time(seconds_subscript)]
    LOW rtccs_pin_ds1302
    time(seconds_subscript) = 10*((time(seconds_subscript)<<9) >> 13) + ((time(seconds_subscript)<<12)>>12)
    RETURN
    readthetime:
    GOSUB readmin
    GOSUB readhr
    GOSUB readsec
    RETURN

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I got nothing except maybe a hardware problem... Are you using a solderless breadboard? Try a different place on the board, or better yet, cann it and get a new one.

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