Action
Read a value from the micro wire bus.
Syntax
MWREAD variable , opcode , address, bytes
Remarks
Variable |
The variable that is assigned with the value retrieved from the micro wire bus. |
Opcode |
The opcode to use. |
Address |
The address of the device. |
Bytes |
Number of bytes to send. |
See also
Example
'-----------------------------------------------------------------
' MicroWire test file
' please read microwire specs for understanding microwire
'-----------------------------------------------------------------
'CS - chip select
'DIN - data in
'DOUT - data Out
'CLOCK- Clock
'AL - address lines
' 93C46 93C56 93C57 93C66
'----------------------------------------------------------------------------
' Data bits: 8 16 8 16 8 16 8 16
' AL : 7 6 9 8 8 7 9 8
'you could use the same pin for DIN and DOUT
'we use a 93C46 and send bytes not words so AL is 7
Config Microwire = Pin , Cs = P1.1 , Din = P1.2 , Dout = P1.4 , Clock = P1.5 , Al = 7
'init pins
Mwinit
'dimension variable used
Dim X As Byte
'enable write to eeprom
'send startbit, opcode (00) and 11 + address
'Mwwopcode opcode, numberOfBits
Mwwopcode &B1001100000 , 10
'the mwwopcode can send a command(opcode) to a device
X = 10
'write value of X to address 0
'opcode is 01
'we write 1 byte
'Mwwrite var,opcode,address,numberOfBytes
Mwwrite X , &B101 , 0 , 1
Waitms 10
X = 0
'read back
' mwread var,opcode,address,numberofbytes
Mwread X , &B110 , 0 , 1
'disable write
'send startbit, opcode (00) and 00 + address
Mwwopcode &B1000000000 , 10
End