Skip to content

Instantly share code, notes, and snippets.

@rafalw
Created October 27, 2014 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafalw/41f096d555add924d58b to your computer and use it in GitHub Desktop.
Save rafalw/41f096d555add924d58b to your computer and use it in GitHub Desktop.
Licznik binarny - demonstracja prostej obsługi magistrali I2C.
' 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