??? 02/17/08 23:35 Modified: 02/17/08 23:45 Read: times |
#150972 - No problem here Responding to: ???'s previous message |
I assume that Your problem is the rising edge appearing at the same time with the data itself. That has propably bee Your trouble with the first try of doing this with a RAM variable.
The following code will force the line low while modifying the data so it should not be latched. The the bit 6 is forced up with the same data. There might be a separate instruction in 8051 to do this bit by bit but it is highly compiler dependant whether You can use it or not. So the solution uses brute force and writes the entire port - the data remains the same. The last write is just to bring the bit 6 low again. This should work for both edge or high level transparent latches. And further more - it does not matter at which edge the latch operates - both will do absolutely fine. Your code would look like: while(1) { { unsigned char string1[]="ABCDEFG"; unsigned char z; for (z=0;z<=7;z++) { P0 = string1[z] & 0x3F; // Data out, bit 6 low P0 = (string1[z] & 0x3F) | 0x40; // Bit 6 high P0 = string1[z] & 0x3F; // Bit 6 low again } } This works IF bit 7 is unused. This can (easily) be modified to store bit 7 state if that bit is used for something. In that case (propably) the best way to do it as this: while(1) { { unsigned char string1[]="ABCDEFG"; unsigned char z; unsigned char mybit7; mybit7 = P0 & 0x80; // Remember bit 7 state for (z=0;z<=7;z++) { P0 = (string1[z] & 0x3F) | mybit7; // Data out, bit 6 low P0 = (string1[z] & 0x3F) | 0x40 | mybit7; // Bit 6 high P0 = (string1[z] & 0x3F) | mybit7; // Bit 6 low again } } |
Topic | Author | Date |
For loop parsing with a rising edge write | 01/01/70 00:00 | |
Forgot to mention | 01/01/70 00:00 | |
Not sure how it should work... | 01/01/70 00:00 | |
I don't quite understand what's your problem... | 01/01/70 00:00 | |
Better clarification of error I hope... | 01/01/70 00:00 | |
No, it would not work | 01/01/70 00:00 | |
yeah. my bad...![]() | 01/01/70 00:00 | |
No problem here | 01/01/70 00:00 | |
Is the string fixed or variable length ? | 01/01/70 00:00 | |
Ment to mention | 01/01/70 00:00 | |
Oh - I C | 01/01/70 00:00 | |
I have the answer thanks to you folks...:) | 01/01/70 00:00 | |
sounds like missing pullups | 01/01/70 00:00 |