Serial transmission and reception

Hello,

In my previous topic http://arduino.cc/forum/index.php/topic,123839.0.html i tried to make serial transmission without timers and interruptions. Looking to previos link i was sending data and writing on ports through delayMicroseconds(x) function. I got many troubles since code it's not time uniform and i was not getting the correct data on the receiving end. I had so many troubles that i have to change the approach.. :(

My setup is: 1x arduino UNO transmits data using MAnchester coding 1x arduino on the receiving end that listens port, gets all bits in an save in variable data. What would it be the easiest, reliable and fast solution to send and receive data?

if data = 0x34 for example i want pinX to be 0011 0100 timed correctly between writes ... So, if i had a signal with 50kHz the time between each write should be 20us.

I have no trouble setting up ISR Timer to generate interrupts every xx us. What i have trouble to understand is how to make ISR write the data that i want without missing a bit...

I'm so confused, lacking solutions..and desperate at the same time because this is part of a project that is close to an end. Every help is appreciated.

Thank you for support, Fernando Oliveira

Are you doing it yourself from scratch? Have you considered using SoftwareSerial, or something based on it if you need a different bit encoding scheme? That should show you how to output a pulse train at the appropriate timing, anyway.

What i have trouble to understand is how to make ISR write the data that i want without missing a bit...

I would set the interrupt to 2x the data rate then

shift/test/output bit in the first interrupt for each bit. output ~bit in the second interrupt for each bit.

Or ~bit then bit, depending on which model you are using.


Rob

PeterH: Are you doing it yourself from scratch?

Yes, trying to. I managed to achieve a transmission for accurate 125kHz using asm "nop" but i realized that the receiving end was too slow to achieve the correct reception. Then, i decreased transmission frequency to 25kHz where delaymicroseconds(X) is accurate according to several sources on this forum. Looking to the oscilloscope there was several pulses where width was longer/shorter than what it should. My remaining sollution was really timer interrupts...

PeterH: Have you considered using SoftwareSerial, or something based on it if you need a different bit encoding scheme? That should show you how to output a pulse train at the appropriate timing, anyway.

Will take a look and see how that solution work for me... As long i can send and receive raw data i am ok...

Thanks