KerimF
Advanced Member level 5
- Joined
- May 17, 2011
- Messages
- 1,554
- Helped
- 376
- Reputation
- 760
- Reaction score
- 379
- Trophy points
- 1,373
- Location
- Aleppo city - Syria
- Activity points
- 13,095
Let us assume that an even number (N) of bits is saved on a table of size (L) bytes, where:.
L = int(N/8) + (mod(N,8)<>0)
Examples:
If N=200 bits, L=25 bytes
If N=202 bits, L=26 bytes
If N=204 bits, L=26 bytes
If N=206 bits, L=26 bytes
If N=208 bits, L=26 bytes
If N=210 bits, L=27 bytes
Etc...
The AVR8 code in question reads a bit from a bit stream table (saved in SRAM, for speed). Then it outputs this bit (0 or 1) to an output pin. When it reaches the Nth bit (the last bit in the table, not the last byte since N may not be a multiple of 8), it restarts from the first bit, for the next cycle.
I found that the minimum number of MCU cycles which is needed by the loop of this code is 4 cycles. This is the best speed I was able to achieve
Anyway, I have the impression that no one here had a good reason, in the past, to be interested in writing such special fast code. Therefore, for your curiosity in the least, I think I will have to post what I did on this thread, after about a week from now (The delay is for the case that my impression could be wrong ).
Cheers,
Kerim
L = int(N/8) + (mod(N,8)<>0)
Examples:
If N=200 bits, L=25 bytes
If N=202 bits, L=26 bytes
If N=204 bits, L=26 bytes
If N=206 bits, L=26 bytes
If N=208 bits, L=26 bytes
If N=210 bits, L=27 bytes
Etc...
The AVR8 code in question reads a bit from a bit stream table (saved in SRAM, for speed). Then it outputs this bit (0 or 1) to an output pin. When it reaches the Nth bit (the last bit in the table, not the last byte since N may not be a multiple of 8), it restarts from the first bit, for the next cycle.
I found that the minimum number of MCU cycles which is needed by the loop of this code is 4 cycles. This is the best speed I was able to achieve
Anyway, I have the impression that no one here had a good reason, in the past, to be interested in writing such special fast code. Therefore, for your curiosity in the least, I think I will have to post what I did on this thread, after about a week from now (The delay is for the case that my impression could be wrong ).
Cheers,
Kerim