in my current project I have to output 8 bytes parallel on an 8 bit wide port. I do it in a very straight forward (or dumb) way, like:
Code: Select all
for (int bit=0; bit<8;bit++) {
unsigned char bit_position = (1<<bit);
unsigned char output = 0;
for (int value=0; value<8;value++) {
if (values[value]&bit_position) {
output|=(1 << value);
}
output_channel <: output;
}
This method is easy to understand but uses up a lot of processing cycles. Is there an better way? Perhaps even using some XMOS assembler magic ;)
Thanks
Marcus