Multiple IO ports are used for bonding selection in many cases of application. However, if the AM4E input port receives high level, the current leakage may occur. Or in some cases of motor system, the leakage may also occur when the input port of positioning point receives high level. To avoid this problem, EzCode4E has included the PraSel instruction, which can change the status of Pra port and thus solve the leakage problem effectively
This article illustrates how to use PraSel instruction by taking the example of motor positioning before it enters into sleep mode.
Instruction Description
PraSel(pra3,pra2,pra1,pra0)
pra(n):{I,O} I means input,O means output.
Ex
PraSel(i,i,o,o) ;Pra3 and Pra2 are set as input. Pra1 and Pra0 are set as output.
AvddPra is a special procedure to mask the input state of Pra port if it is used for other functions. And it can also prevent the interference caused by Pra port status change when scanning key-press.
Ex
[Procedure]
Avddpra
{
Andia B’0001’
}
This procedure is to ignore Pra1, Pra2, and Pra3 pins when scanning key-press in EzCode4E.
Program Function Description
The following takes motor as an example to explain program function.
After power on, the Prb3 can trigger motor to rotate. Until the Prb3 contacts the high level, the motor will stop rotating. Then the input state of pin is changed to output state and output high level, finally it enters into sleep mode.
Another function, after Pra2 is pressed, it will trigger midi playing and motor rotating. Until the playing is ended and the point contacts the high level, it will stop rotating. Then the pin input state is changed to output state and output high level, finally it enters into sleep mode.
Setting Steps
1. Create a file and select an AM4E Body (e.g. AM4EC005).
2. Fill in client name (agent name) in Project page.
3. Add Melody.
4. Set input and output pin as the figure1 shows.
... ...
PraSel.rar