I'm trying to feed a 7seg LEDdriver bit bashing a STP08C05 and with a
11.059M clock it takes about 180uS. Any way to speed it up, (and I am going up to 24Mhz xtal) ?
void Led7(char time) { char buff,i; bit SDI; buff=seg7[time];
for(i=0; i>1;
P1|=0x80;//clock P1&=~0x80; } }
Thanks
martin
Didn't find your answer? Ask the community — no account required.
N
Niklas Holsti
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?
I'm not very good at programming, I'm just trying Niklas's approach, and thanks for the bit instruction tip
martin
M
Martin Griffith
Thanks, I'm reading the Raisonace documents now, _bit is different, it appears. It's a vast improvement over my original :)
martin
N
Niklas Holsti
Correcting my own post:
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:
formatting link
It's going quite well.
back to the docs....
martin
M
Martin Griffith
oops, got 2 part numbers mixed up STP16C596 or STP16CP05 from ST micro, still waiting for the to be delivered from farnell spain
martin
M
Martin Griffith
I hope so. I have a mate with a small assembly shop in the uk, he's much better at soldering than I am. A bit more here
formatting link
martin
D
donald
Are you making the Timecode grabber code on the PC available ??
D
donald
Google can not find "STP08C05", do you have a link ??
donald
M
Moon Shine
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.
asm("nop");
M
Moon Shine
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.
asm("nop");
M
Moon Shine
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.
asm("nop");
M
Martin Griffith
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
51, its what I'm used to
martin
M
Martin Griffith
I think your read-modify-post needs adjusting :)
martin
M
Moon Shine
router locked up and hickuped. :-/
If you are stuck on 8051s, there are some crazy fast ones out there. 200mhz.
formatting link
Or pick one with high mips here.
formatting link
C
CBFalconer
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?
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.