Another Shiftout question


Results 1 to 4 of 4

Threaded View

  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

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 : 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