Abl-electronic PIC Microcontrollers PIC16 Manuel d'utilisateur Page 281

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 312
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 280
The example demonstrates simple data exchange via USART. When PIC MCU
receives data, it immediately sends the same data back. If PIC is connected to the
PC (see the figure below), you can test the example from mikroC terminal for
RS232 communication, menu choice Tools > Terminal.
MikroElektronika:
Development
tools
-
Books
-
Compilers
273
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Prototype
char Usart_Write(char data);
Description Function transmits a byte (data) via USART.
Requires USART HW module must be initialized and communication established before using
this function. See
Usart_Init.
Example
int chunk;
...
Usart_Write(chunk);
/* send data chunk via USART */
Usart_Write
Library Example
unsigned short i;
void main() {
// Initialize USART module (8 bit, 2400 baud rate, no parity bit..)
Usart_Init(2400);
do {
if (Usart_Data_Ready()) {
// If data is received
i = Usart_Read();
// Read the received data
Usart_Write(i);
// Send data via USART
}
} while (1);
}
//~!
Vue de la page 280
1 2 ... 276 277 278 279 280 281 282 283 284 285 286 ... 311 312

Commentaires sur ces manuels

Pas de commentaire