Added problem: I really don't understand the part MikroC states:
The Manchester receive routines are blocking calls (Man_Receive_Init and Man_Synchro). This means that MCU will wait until the task has been performed (e.g. byte is received, synchronization achieved, etc).
Manchester code library implements time-based activities, so interrupts need to be disabled when using it.
On the other hand, the example code given in the help directory states that the timer is enabled after the Man_Receive_Init is called. Can somebody explain this? Doesn't this mean that the interrupt enabled will affect the Man_Receive_Init?
Okay so here's a bit of code-fu that I'm trying out:
C:
while(1){
gie_bit = 1; // Global interrupt enable
t0ie_bit = 1; // Enable Timer0 overflow interrupt
data_ = Man_Receive(&error); // Attempt byte receive
gie_bit = 0;
if (error) { // If error occured
ErrorCount++; // Update error counter
if (ErrorCount > 20) { // In case of multiple errors
//data_ = Man_Synchro(); // Try to synchronize again
Man_Receive_Init(); // Alternative, try to Initialize Receiver again
ErrorCount = 0; // Reset error counter
}
}
if (data_ != 0xfa){
Indicator = 0;
}
if (data_ == 0xfa){
Indicator = 1;
}
}
I've tried an interrupt routine but the example in the MikroC help directory puts it too simply. Anyone can suggest if I'm going in the right direction here?
Right now it's still the same. A wire-to-wire transmission works-ish but not wireless. It seems my first code worked best.