



The benefit is that the main program can run at 100% of the potential throughput most of the time. In your code, the main program halts whenever a byte needs to be transmitted, or whenever a byte arrives. The drawback is that the main program can only ever achieve around 40% of the throughput that could otherwise be available for a given clock speed. The operation is fundamentally half-duplex.Ģ) In my code, the main program continues to execute as bytes are transmitted or received. In your code, if an incoming byte starts to arrive while the program was in the middle of transmitting an outgoing byte, the outgoing byte will halt and resume again after the incoming byte is finished. If you're in the middle of transmitting a byte, and an incoming byte starts, then the two will coexist. Here's my take on the functional comparison:ġ) In my code, you can be transmitting and receiving simultaneously (Full duplex). External Interrupt(s) initialization (for RX) GICR &= 0圎F //Las interrupciones externas se paran For example by changing 0x0B in the UCSRA macro we can access UCSRA registers in different controllers without changing register address in our code.Interrupt void ext_int0_isr(void) The whole reason for all this is to make code more portable.

UCSRA register and applies mask for bit #7 in it. In the end you get yourself a code that reads Since _MMIO_BYTE and _SFR_OFFSET are also macros, the process continues until all macro directives processed. Transforms the code further into while (!(_MMIO_BYTE((0x0B) + _SFR_OFFSET) & 0x80)) Then the macro #define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + _SFR_OFFSET) For different controller "RCX" macro can have different value.Īnd just in case you are wondering, "UCSRA" and "UDR" in your code are also two macro definitions referencing another macro, _SFR_IO8. Note, that I've given you an example for ATmega32. So, while() will exit immediately, because it is expanded into Which is the number of the RXC bit in UCSRA register.
