Datasheet

Soft_UART_Break
419
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Prototype
void Soft_UART_Break();
Returns Nothing.
Description
Soft_UART_Read is blocking routine and it can block the program flow. Call this
routine from interrupt to unblock the program execution. This mechanism is simi-
lar to WDT.
Note: Interrupts should be disabled before using Software UART routines again
(see note at the top of this page).
Requires Nothing.
Example
char data1, error, counter = 0;
void Timer0Overflow_ISR() org 0x12 {
if (counter >= 20) {
Soft_UART_Break();
counter = 0; // reset counter
}
else
counter++; // increment counter
}
void main() {
TOIE0_bit = 1; // Timer0 overflow inter-
rupt enable
TCCR0_bit = 5; // Start timer with 1024
prescaler
SREG_I = 0; // Interrupt disable
...
Soft_UART_Init(9600);
Soft_UART_Write(0x55);
...
// try Soft_UART_Read with blocking prevention mechanism
SREG_I_bit = 1; // Interrupt enable
data1 = Soft_UART_Read(&error);
SREG_I_bit = 0; // Interrupt disable
...
}