Bitte schön (stilistisch miserabel, aber dafür hoffentlich gut verständlich):
Code: Alles auswählen
$regfile = "atTiny85.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 1000000
' Pins:
' 1 v 8
' 2 7
' 3 6
' 4 5
'
' 1 = RESET -> 10K an +5V;
' 2 = PB3/ADC3 -> RCLK 74595 (Pin12)
' 3 = PB4/ADC2 -> Poti
' 4 = GND
' 8 = +5V
' 7 = PB2(SCK) -> CLK 74595 (Pin11)
' 6 = PB1(MISO) -> nc
' 5 = PB0(MOSI) -> SERIN 74595 (Pin14)
Dim I1 As Byte
Config Portb.0 = Output 'SERIN 74595
' Config Portb.1 = Output 'Nicht benutzt
Config Portb.2 = Output 'CLK 74595
Config Portb.3 = Output 'RCLK 74595
Mosi Alias Portb.0
Sck Alias Portb.2
Set Portb.2 'CLK 74595 Leitung auf High
Set Portb.3 'RCLK 74595 Leitung auf High
I1 = 0
'Alles auf 0 initialisieren
Shiftout Mosi , Sck , I1 , 2 , 8 , 20
Waitus 20
Reset Portb.3 'low Strobe an RCLK 74595
Waitus 20
Set Portb.3 'RCLK 74595 Leitung wieder auf High
Waitms 100
Do
'Bitmuster rausschieben
I1 = &B00000001
Shiftout Mosi , Sck , I1 , 2 , 8 , 20
Waitus 20
Reset Portb.3 'low Strobe an RCLK 74595
Waitus 20
Set Portb.3 'RCLK 74595 Leitung wieder auf High
Waitms 500
I1 = &B00000010
Shiftout Mosi , Sck , I1 , 2 , 8 , 20
Waitus 20
Reset Portb.3 'low Strobe an RCLK 74595
Waitus 20
Set Portb.3 'RCLK 74595 Leitung wieder auf High
Waitms 500
I1 = &B00000100
Shiftout Mosi , Sck , I1 , 2 , 8 , 20
Waitus 20
Reset Portb.3 'low Strobe an RCLK 74595
Waitus 20
Set Portb.3 'RCLK 74595 Leitung wieder auf High
Waitms 500
I1 = &B00001000
Shiftout Mosi , Sck , I1 , 2 , 8 , 20
Waitus 20
Reset Portb.3 'low Strobe an RCLK 74595
Waitus 20
Set Portb.3 'RCLK 74595 Leitung wieder auf High
Waitms 500
I1 = &B00010000
Shiftout Mosi , Sck , I1 , 2 , 8 , 20
Waitus 20
Reset Portb.3 'low Strobe an RCLK 74595
Waitus 20
Set Portb.3 'RCLK 74595 Leitung wieder auf High
Waitms 500
I1 = &B00100000
Shiftout Mosi , Sck , I1 , 2 , 8 , 20
Waitus 20
Reset Portb.3 'low Strobe an RCLK 74595
Waitus 20
Set Portb.3 'RCLK 74595 Leitung wieder auf High
Waitms 500
I1 = &B01000000
Shiftout Mosi , Sck , I1 , 2 , 8 , 20
Waitus 20
Reset Portb.3 'low Strobe an RCLK 74595
Waitus 20
Set Portb.3 'RCLK 74595 Leitung wieder auf High
Waitms 500
I1 = &B10000000
Shiftout Mosi , Sck , I1 , 2 , 8 , 20
Waitus 20
Reset Portb.3 'low Strobe an RCLK 74595
Waitus 20
Set Portb.3 'RCLK 74595 Leitung wieder auf High
Waitms 500
Loop