mikroC

making it simple...

Software UART Library

mikroC - C Compiler for Microchip PIC microcontrollers

mikroC provides library which implements software UART. These routines are hardware independent and can be used with any MCU. You can easily communicate with other devices via RS232 protocol – simply use the functions listed below.

Note: This library implements time-based activities, so interrupts need to be disabled when using Soft UART.

Library Routines

Soft_Uart_Init

Soft_Uart_Read

Soft_Uart_Write

Soft_Uart_Init

Prototype

void Soft_Uart_Init(unsigned short *port, unsigned short rx,

 

unsigned short tx, unsigned short baud_rate, char inverted);

Description Initalizes software UART. Parameter port specifies port of MCU on which RX and TX pins are located; parameters rx and tx need to be in range 0–7 and cannot point at the same pin; baud_rate is the desired baud rate. Maximum baud rate depends on PIC’s clock and working conditions. Parameter inverted, if set to non-zero value, indicates inverted logic on output.

Soft_Uart_Init needs to be called before using other functions from Soft UART Library.

Example

Soft_Uart_Init(&PORTB, 1, 2, 9600, 0);

 

 

page

 

MikroElektronika: Development tools - Books - Compilers

261