Created
October 27, 2014 20:37
-
-
Save rafalw/41f096d555add924d58b to your computer and use it in GitHub Desktop.
Licznik binarny - demonstracja prostej obsługi magistrali I2C.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Licznik binarny - demonstracja prostej obsługi magistrali I2C. | |
' - element master - MCU | |
' - element slave - PCF8574AP (ekspander magistrali I2C) | |
' Sterowanie LED-ami (zwrócić uwagę na prawidłowy sposób zasilania LED-ów przez PCD8574AP) | |
$regfile = "attiny2313.dat" | |
$Crystal=4000000 | |
$hwstack=40 | |
$swstack=16 | |
$framesize=32 | |
' Adres do zapisu ekspandera I2C | |
Const Addr_0 = &B01110000 | |
' Konfiguracja pinów magistrali I2C | |
Config Scl = Portb.7 | |
Config Sda = Portb.5 | |
Dim I As Byte | |
I = 255 | |
Do | |
' Wariant 1 - prostszy, możliwy tylkow szczególnych przypadkach - jak ten! | |
' I2csend Addr_0 , I | |
' Wariant drugi, stosowany przy bardziej skomplikowanych układach | |
I2cstart | |
I2cwbyte Addr_0 | |
I2cwbyte I | |
I2cstop | |
Decr I | |
Waitms 100 | |
Loop | |
End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment