Newbie 74hc595 question


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    First of all, Thanks darren for the quick reply.
    so i need to put an extra pin - can i use porta.2?
    and just take it low and high before and after shifting right?
    Thanks again,
    Shahar

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by manjero View Post
    First of all, Thanks darren for the quick reply.
    No problem Shaharn.

    >> so i need to put an extra pin - can i use porta.2?

    Yes!
    But before you can use any of the PORTA pins, including the ones you have already used, you need to turn off the Analog functions.

    CMCON0 = 7
    ANSEL = 0

    >> and just take it low and high before and after shifting right?

    A simple HIGH/LOW toggle of the Latch after shifting will do it. The 595 is a very fast chip.

    But there are more problems too.
    Code:
    Main:
        sleep 1000
        Shiftout D1PIN, C1PIN, MSBFIRST,[0]
        goto Main 
    end
    sleep 1000 will put the PIC in low power mode for somewhere around 1000 seconds. (16 minutes, 40 seconds)

    sleep 60 would be closer to 1-minute, but it'll only be "somewhere around" a minute, since it uses the Watch Dog Timer..

    PAUSE 60000 ; would be a better approximation, without resorting to Timers.<hr>
    >> Shiftout D1PIN, C1PIN, MSBFIRST,[0]
    That's going to shift out 8-bits. So 8 of the LED's will turn off at the same time.

    The way you're doing it, you don't really need the shiftout statement in the Main loop.

    First, set the Data pin to 0 before going into the loop.
    Then after each minute toggle the Clock pin once, to shift in a 0.
    Then toggle the Latch Pin, to move the data to the 595's output's.

    <hr>Also, the first ShiftOut's can be combined...
    Code:
    Shiftout D1PIN, C1PIN, MSBFIRST,[bvar, bvar, bvar, bvar]
    <br>
    DT

  3. #3
    Join Date
    Jan 2008
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Hey DT.
    Thanks again - that was very informative!
    I changed my code to this:

    Include "modedefs.bas" ' Include shift modes

    CMCON0 = 7
    ANSEL = 0
    DPIN var PORTA.0 ' Shift data pin 1
    CPIN var PORTA.1 ' Shift clock pin 1
    LPIN var PORTA.2 ' Latch pin 1


    bvar var BYTE

    bvar = 255
    ' Shift out 8 bits of data onto other pins
    Shiftout DPIN, CPIN, MSBFIRST,[bvar, bvar, bvar, bvar]
    Low DPIN

    Main:
    pause 5980
    High CPIN
    pause 10
    'Shiftout D1PIN, C1PIN, MSBFIRST,[0]
    LOW CPIN
    Pulsout LPIN,10
    goto Main
    end

    Compiles OK so lets hope :-)

  4. #4
    Join Date
    Jan 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Hello manjero, I think that Darrel missed the fact that you're using an 'F84. You can drop the:-

    CMCON0 = 7
    ANSEL = 0

    The 'F84 doesn't have any analogue inputs to turn off or configure as digital IO. They're always digital IO. In fact, I have 16F84(A) selected, the compiler, (v 2.44), doesn't even recognise CMCON0.

    ... Steve (Yep, another one)

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scarroll01 View Post
    In fact, I have 16F84(A) selected, the compiler, (v 2.44), doesn't even recognise CMCON0.
    ... Steve (Yep, another one)
    The upgrade covers that too, only $25.
    Get your now...hurry hurry hurry.

Similar Threads

  1. newbie with serial com question...
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th December 2006, 05:34
  2. Newbie Question - Info Please
    By ehoskins in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd October 2006, 14:50
  3. Greetings from Newbie and a question
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th July 2006, 15:52
  4. Newbie question
    By senojlr in forum General
    Replies: 7
    Last Post: - 11th April 2006, 21:23
  5. Replies: 4
    Last Post: - 8th September 2005, 15:42

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