Srigopal007
- 18th August 2004, 04:58
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
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