User manual

mikroC PRO for dsPIC
MikroElektronika
487
Soft_UART_Break
Prototype
void Soft_UART_Break();
Description Soft_UART_Read is blocking routine and it can block the program ow. Calling Soft_UART_Break
routine from the interrupt will unblock the program execution. This mechanism is similar to WDT.
Parameters None.
Returns Nothing.
Requires Nothing.
Example
char data1, error, counter = 0;
void Timer1Int() org IVT_ADDR_T1INTERRUPT {
if (counter >= 20) {
Soft_UART_Break();
counter = 0; // reset counter
}
else
counter++; // increment counter
T1IF_bit = 0; // Clear Timer1 overow interrupt ag
}
void main() {
...
if (Soft_UART_Init(&PORTF, 4, 5, 14400, 0) = 0)
Soft_UART_Write(0x55);
...
// try Soft_UART_Read with blocking prevention mechanism
IPC0 = IPC0 | 0x1000; // Interrupt priority level = 1
T1IE_bit= 1; // Enable Timer1 interrupts
T1CON = 0x8030; // Timer1 ON, internal clock FCY, prescaler 1:256
data1 = Soft_UART_Read(&error);
T1IE_bit= 0; // Disable Timer1 interrupts
}
Notes The Software UART library implements time-based activities, so interrupts need to be disabled when
using it.