MikroElektronika PIC Microcontrollers PIC16 Manual de usuario Pagina 157

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 172
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 156
sub procedure RS485master_write(dim byref data as byte[2],
dim datalen as byte, dim address as byte)
MCU must be initialized as Master in 485 communication. It is programmer's
responsibility to ensure (by protocol) that only one device sends data via 485 bus
at a time.
dim byref data as byte[2], dim datalen as byte
Sends number of bytes (1 < datalen <= 3) from buffer via 485.
sub procedure RS485slave_read(dim byref data as byte[5])
MCU must be initialized as Slave in 485 communication.
dim byref data as byte[5]
Only messages that appropriately address Slaves will be received. As messages are
multi-byte, this procedure must be called for each byte received (see the example
at the end of the chapter). Upon receiving a message, buffer is filled with the fol-
lowing values:
data[0..2] is data; data[3] is number of bytes received (1..3) ; data[4] is set to
255(TRUE) when message is received; data[5] is set to 255(TRUE) if an error has
occurred; rest of the buffer is undefined
Procedure automatically sets data[4] and data[5] upon every received message.
These flags need to be cleared repeatedly from the program.
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
152
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
making it simple...
page
RS485master_write
Prototype:
Parameters:
Effects:
Precondition:
RS485slave_read
Prototype:
Parameters:
Effects:
Precondition:
Vista de pagina 156
1 2 ... 152 153 154 155 156 157 158 159 160 161 162 ... 171 172

Comentarios a estos manuales

Sin comentarios