Another Shiftout question


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Location
    CA
    Posts
    78

    Post Another Shiftout question

    okay ppl. I just want to know if my usage of shiftout is actually correct.. I looked at the PBP manual and they had an example which I found useful but not sure if I am using it correctly. In my program I use this format.
    SHIFTOUT DATAPIN, CLOCKPIN, MODE, [VAR\bits]

    PORTC.6 is where I send my data out while PORTB.3 is where I generate the clock and and data is transfered when clock goes high. which presumes MODE 1. and my goal is to send 16 bits through Portc.6

    below is a sample code from my program ...

    One problem which I am seeing is that i dont notice any changes in the outputs {LEDS}. is it because I am using an external clock which is 20Mhz . How can I notice the changes between the two shiftout that I am sending. Dont konw where or how I can slow things down besides using a slower clock .. but that is something I dont want to do. so please help. Also if there are any mistakes that I have in my program please mention them.

    ----------------program stars here--------------
    INCLUDE "modedefs.bas"

    i VAR BYTE
    Flag1 VAR BYTE
    Flag2 VAR BYTE
    Count_send VAR BYTE
    Latch VAR PortB.0
    Chip_Enable VAR PortB.1
    slug1 VAR WORD
    slug2 VAR WORD
    TRISC =%00000000
    TRISB =%00000000
    slug1 =$4676 'data that need to be sent out
    slug2 =$7777 'data that need to be sent out

    start:
    Low Latch
    High Chip_Enable
    Count_send = 0
    While(Latch == 0) && (Chip_Enable == 1)
    Count_send = Count_send + 1 'counter to keep track of what data is sent out
    if(Count_send == 1) then SEND1 'first data need to be sent out
    if(Count_send == 1) then SET_FLAG

    if(Count_send == 2) then SEND2 'second data need to be sent out
    if(Count_send == 2) then SET_FLAG
    if(Count_send == 2) then RESET_COUNT

    if(Latch == 1) then
    Low Chip_Enable 'activating the chip
    Low Latch 'data is being latched
    High Chip_Enable
    endif
    Wend

    SEND1:
    For i = 1 to 100 'repeating the signal for 100 times
    ShiftOut PortC.6, Portb.3, [slug1\16]
    Next i
    return

    SEND2:
    For i = 0 to 100 'repeating the signal for 100 times
    ShiftOut PortC.6, Portb.3, [slug2\16]
    Next i
    return

    SET_FLAG:
    High Latch
    return

    RESET_COUNT:
    COUNT_SEND = 0
    return
    Attached Files Attached Files

  2. #2
    Hawkesy's Avatar
    Hawkesy Guest


    Did you find this post helpful? Yes | No

    Default

    I am no expert but maybe you could try the shift_pauseus command that will slow your shift clock down, however it is in micro seconds, so you may not see any changes.

    Cheers

  3. #3
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    One problem which I am seeing is that i dont notice any changes in the outputs {LEDS}. is it because I am using an external clock which is 20Mhz .

    I didn't take a real close look at your code, but at the speed your little chip is doing, LED's ain't going to cut it. Unless their is someway to do at least pause longer than 1/30th of a second. 1/30th of a second (if I remember correctly) is the frame rate on TV's. And TV's actions seems smooth to our eyes. I am sure your chip is running a whale of a lot faster. Can you scope it with a trigger and memory? Just send one slug and scope it... that way you can verify trans?. I would suggest putting the LED's on your *receiver*. And see what the receiver is receiving. Or just send the slug 00000001, and see if the receiver lights up only one LED after the send.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Using RETURN in your sub-routines won't work unless you're using GOSUB to get to them.

    if(Count_send == 2) then RESET_COUNT

    The above is the same as using --

    if(Count_send ==2) THEN GOTO RESET_COUNT

    The GOTO is "implied" in the 1st version even though it's not physically inserted. GOSUB is what you'll need to use if you're using RETURN in all your sub-routines.

    RETURN pops the return address from the stack so it knows where to RETURN to. Unless you've used GOSUB, you haven't pushed any return address onto the stack.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. 7 Segment Displays and MAX7219
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st October 2010, 18:30
  2. Using MAX 7221 LED driver
    By Nick in forum mel PIC BASIC
    Replies: 15
    Last Post: - 21st October 2010, 19:31
  3. Smart Star (how to use shift registers)
    By mackrackit in forum Code Examples
    Replies: 3
    Last Post: - 30th November 2008, 20:06
  4. Shiftout question.
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd April 2007, 15:57
  5. Shorter Subroutines for MAX7219
    By exelanoz in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th March 2007, 11:35

Members who have read this thread : 1

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