We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Dose anybody know the purpose of doing this
void Send_CmdNo(unsigned char command){ CSX=0; RDX=1; D_CX=0; DBUS=command; WRX=0; WRX=0; WRX=0; WRX=1; CSX=1; }
why use WRX=0 3 times b4 WRX=1? wouldn't that just give you WRX=1?
by the way WRX is just
sbit WRX = P7^2;
does it mean on the I/O pin the output will send out 0 three times and 1 one time? It performs that fast?
Since no one actually answered your request, here goes.
This looks like a byte wide interface to a peripheral with ChipSelect(CSX), Read(RDX), Data/Command(D_CX), and Write(WRX) using individual I/O pins and DBUS as the eight bit bus.
The first line "CSX=0" drives the Chip Select low and selects the device. Note: the chip select remains low till the last instruction of the function.
Subsequent lines set Command mode, put the data on the bus, and pulse the Write line (a normally high signal with a low going pulse to write data).
WRX=0 repeated three times does not actually change the port pin three times, it just kills time, perhaps to allow the peripheral time to capture the incoming data.
"no one actually answered your request"
Yes they did - and also his subsequent request which followed-on from that answer!
A Clearer solution might be to use the _nop_ macro
void Send_CmdNo(unsigned char command) { CSX = 0; RDX = 1; D_CX = 0; DBUS = command; WRX = 0; _nop_; // Short Delay _nop_; WRX = 1; CSX = 1; }
Of course the timing would need to be verified
Note that _nop_ is an Intrinsic Function - so the code should be:
void Send_CmdNo(unsigned char command) { CSX = 0; RDX = 1; D_CX = 0; DBUS = command; WRX = 0; _nop_(); // Short Delay _nop_(); WRX = 1; CSX = 1; }
note the parentheses.
http://www.keil.com/support/man/docs/c51/c51__nop_.htm
thanks guys... so many replies altho most is a bit off the topic but I still appreciate it ^^ I will study into it :)