Playing around with SDCC and counting cycles with a WCET tool, assuming a vanilla 8051 with 12 clocks per machine cycle, the fastest looping version I found is 145 us:
buff=seg7[time]; P1 &= ~0x20; i = 8; do { if (buff & 0x01) { P1 ^= 0x20;}
buff = buff >> 1;
P1 |= 0x80; //clock P1 &= ~0x80;
i --; } while (i != 0); }
This assumes that seg7[] is in xdata and has been modified to show the changes in segment on/off state, counting from bit 0 to bit 7 and starting from '0' state, so that P1 can be updated with an xor after being initialized to a '0' state before the loop.
The SDCC code from the unrolled function looks quite tight, but I think there are some unnecessary moves from R2 into A that could be avoided in assembly language.
Please note that this code is not tested, just compiled and analysed with a cycle-counting tool.
By the way, I'm not familiar with 7-segment drivers, but I was surprised to see that the code sends 8 bits, not 7. Is that right? What is the 8th bit used for?
To follow the SDCC manual, it is better to write "__sbit" than "__bit" in these declarations. However, it seems to make no difference in the machine code, maybe because of the "__at".
Martin, which compiler are you using? SDCC or a commercial one?
I'm using the 4k limited Raisonace compiler, freeware which is good enough for me. I am not really a programmer, I just have ideas that need a micro, so I attempt to programme
I'm making a SMPTE timecode reader, which has interrupts every 250uS, or so, so I'm trying to speed things up. There are some (bad) videos, all very short, here:
Don't know why you want it so fast? I see a potential problem. Hitting the port pins in two consecutive instructions is a no-no. The port is read-modified-write meaning the second instruction could read invalid value due to capacitance on pin.
Add a nop. Perhaps two. Read your chip spec to see what is required.
Don't know why you want it so fast? I see a potential problem. Hitting the port pins in two consecutive instructions is a no-no. The port is read-modified-write meaning the second instruction could read invalid value due to capacitance on pin.
Add a nop. Perhaps two. Read your chip spec to see what is required.
Don't know why you want it so fast? I see a potential problem. Hitting the port pins in two consecutive instructions is a no-no. The port is read-modified-write meaning the second instruction could read invalid value due to capacitance on pin.
Add a nop. Perhaps two. Read your chip spec to see what is required.
It scopes out ok, and the base code has been running solidly for the last 2 months, on a couple of hand built stripboards
I have a datastream coming in with an interrupt every 250uS or 500uS, (possibly faster) data dependent, in Biphase encoding, I am already having to decode the binary into ascii by masking things, and I am doing everything in between the the clock pulses, just a small amount, every 8 clocks, the interrupts can't be turned off, or I loose data, or worse sync with the data stream
Each 8051 step seems to take a couple of uS, and it very quickly adds up, especially if I have to jump to #include stuff and back again
I some problems with the LCD version, as it took the LCD busy flag up to 37uS to clear, so it was just one write per clock
I used to "do video" in TV studios, so this stuff is really extremely slow, but so is the processor, and at my age I'd need at least a year to figure out the MSP430 or ATmegas,.Just trying to get AVRstudio/GCC running gave me the hiccups. I don't particularly like or dislike the
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.