The mega 8535 is not overclocked, it is running at its own normal speed (being 8 MHz coming from a crystal).
Your hint for the timing between setting the serial input and settings of SCLK=1 sounds like a good idea.
I’ll be happy to show you the code of my routine that sends the data to the 74hc595’s.
(come to think of it; i already tried building in a delay but that didn’t work out, never thought of the NOP’s though.. good idea!)
In my routine i use two databytes for controlling the SID.
1: shiftctrl = holds the addressreg for the data
2: shiftdata= holds the data for that address
And one more:
3: portcout = contains the data that will be put on the port (i do this so i can alter the bits without disturbing any real outputs on portc, this way only
the correct byte appears on the port C)
Reset bit is being set in the routine here below, as well as the controls for sending the bits to the 74hc595s
Hope you can read it well..
Sendportc:
SendportcSetup:
ldi temp,16
sts shiftcount,temp
lds temp,portcout ;keep CS low
cbr temp,CS ;
sts portcout,temp ;
lds temp,shiftctrl ;keep reset high on SID
sbr temp,sidreset ;
sts shiftctrl,temp ;
sendportlus:
lds temp,portcout
cbr temp,RCLK ;outputs 74hc595 low, do not show
cbr temp,SCLK ;SCLK clockbit keep it low
sts portcout,temp
out portc,temp
sendcrotate:
lds temp,shiftctrl
clc
ror temp ;shift first ctrlbyte
sts shiftctrl,temp
lds temp,shiftdata
ror temp ;shift second databyte
sts shiftdata,temp
brcs sendwelcarry ;carry set?
sendgeencarry:
lds temp,portcout
cbr temp,serdat
sts portcout,temp
rjmp sendport
sendwelcarry:
lds temp,portcout
sbr temp,serdat
sts portcout,temp
sendport:
lds temp,portcout
out portc,temp ;portcout op port C zetten
lds temp,portcout
sbr temp,sclk ;SLCK clock high
sts portcout,temp
out portc,temp
lds temp,portcout
cbr temp,sclk ;SLCK clock low
sts portcout,temp
out portc,temp
lds temp,shiftcount ;clkcounter test all 16 bits
dec temp
sts shiftcount,temp
brne sendportlus ;
;rjmp sendportcshow
SendportcShow:
lds temp,portcout ;RCLK high, show the outputs....
sbr temp,RCLK
sts portcout,temp
out portc,temp
lds temp,portcout ;RCLK low
cbr temp,RCLK
sts portcout,temp
out portc,temp
SendPortcEnd:
ret
EDIT: I’ve noticed I’ve never actually made CS low on the port nor do I make it high in the routine..hmmm
I’ll try to make CS high, show on port
then transfer bits to 74 hc595
make CS low, show on port
and show bits 74hc595 to SID
And insert a few NOP here and there..