
Originally Posted by
manjero
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>
Bookmarks