??? 03/03/06 09:04 Read: times |
#111151 - request for comment on comment Responding to: ???'s previous message |
Richard,
Thanks for your comments; but I would like to ask you to comment on your comments :-) further... Richard Erlacher said:
I keep wondering why one would want that software-FIFO. There's probably good reason, but I've not found it. The example is to be viewed in the context of Jon's document. Jon gives reasons for usage of interrupt-driven software-FIFO-buffered serial communication there; maybe an example would be fine. But one thing first: it really does not matter if software- or hardware-FIFO, the question is, whether FIFO is needed at all (using the internal UART of '51, the hardware FIFO is then ruled out). The answer is simple, this all is for the convenience of programmer. If the programmer can ensure that the receiver is checked often enough, and/or can spend time to trnasmit a string, then no need for FIFO. If the programmer wants to have some time for a relatively lengthy process and there is chance that bytes will arrive and he does not want to loose them; and/or if he wants to transmit a string (a packet of data) and don't want to wait until it gets actually transmitted, then he needs the FIFO. That's all. A good example is a packet-based communication network. Let's assume a simple example: a packet of 10 bytes arrives, say at 9600 bauds, the controller processes it and is supposed to transmit a 10 bytes packet answer. The "main" program is a loop, where the mcu reads status of some pushbuttons, displays some data, reads some ADC and writes ocassionally into an EEPROM - the loop may take more than 1ms, which is approximately the time it takes for one byte to arrive; hence more than one character might arrive while the loop is executing and if (without interrupt and FIFO) the receiver would be checked only once per loop, characters might get lost. The loop then would have to be broken up into pieces and the receiver checking routine would have to be inserted on more places. Using interrupt and FIFO, there is simply only one place in the loop, where a complete packet reception is checked; and only if it happens, then the packet processing routine is invoked. It produces an outgoing packet, and not to waste time transmitting it byte by byte (which would take 10 ms for 10 bytes), it simply stores it into the output FIFO and starts the transmission. While it happily can resume the main loop, the interrupt takes care of transmitting the whole packet "in background". Is this a good example? Richard Erlacher said:
Also, if I were presenting something to a group of neophytes, I'd certainly make it clear which assembler syntax was in use and what intrinsics there were. Not everybody knows what you assume they know, particularly when you assume certain, perhaps well-known, constants/parameters are known. Hmmmm... Maybe some specific header is missing, but I believe this can be assembled by any '51 assembler, can't it? I thought the '51 assemblers all assume a basic set of 8051 registers to be implicitly known; Keil for example requires to de-activate these to be able to include a custom set of register definitions, but I don't know all the '51 assemblers around... Can you perhaps correct it to be assembler-independent? Richard Erlacher said:
Another thing ... if you have routines that would be called putc or getc or the like in 'C', why not use those names in assembler? They're meaningful and easy to recall and that will help anybody to understand your code. The names of character input/output in C are a bad joke. There is getc, getch, getche, getchar, fgetc, fgetchar (maybe more) providing similar or same functionality with little differences. More importantly, don't expect this from ME, I hate C. Richard Erlacher said:
Long labels in assembler don't make for very pretty code, either, BTW. [...]
Creative use of upper and lower case is helpful, too. [...] Programming style... In asm, I think there are no established rules. We can try to put down some here, if you want, but don't expect everybody be happy with them; I think everybody makes up his own style. I just don't think this is the right place to discuss style; as I said the program itself is not of such importance as the comments on it are. Jan Waclawek |
Topic | Author | Date |
interrupt driven serial: RFC | 01/01/70 00:00 | |
It must be perfect! | 01/01/70 00:00 | |
I don't believe | 01/01/70 00:00 | |
Validation | 01/01/70 00:00 | |
well ... I've looked at it ... | 01/01/70 00:00 | |
request for comment on comment | 01/01/70 00:00 | |
let's take this a little at a time ... | 01/01/70 00:00 | |
OK then give yours | 01/01/70 00:00 | |
Intel Original | 01/01/70 00:00 | |
on byte buffer | 01/01/70 00:00 | |
c version | 01/01/70 00:00 | |
Coloring | 01/01/70 00:00 | |
html syntax colouring | 01/01/70 00:00 | |
to C or not to C | 01/01/70 00:00 | |
yeah but thats the point | 01/01/70 00:00 | |
How true for "real C" | 01/01/70 00:00 | |
excellent idea![]() | 01/01/70 00:00 | |
asm, in the same style | 01/01/70 00:00 | |
This may not work well ... | 01/01/70 00:00 | |
How? | 01/01/70 00:00 |