| Author |
Message |
pjc30943
Joined: 02 Dec 2005
|
|
Posted: 23 July 2008, 19:57 PM Post subject: Toggle Pin vs. High/Low |
|
|
zxOutputToggle does something slightly different than switching to the complementary output state: there seems to be a decay in one direction, making for transitions that are not sharp and don't reach logic level thresholds for quick toggles.
Just curious why this occurs... |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 24 July 2008, 0:16 AM Post subject: Re: Toggle Pin vs. High/Low |
|
|
| pjc30943 wrote: | | there seems to be a decay in one direction | That description strongly suggests that the pin wasn't an output before the call to toggle the pin. If the pin is an input, calling PutPin() with zxOutputToggle simply toggles the state of the pullup resistor (enabled or not). The description of PutPin() clearly states that the pin must be an output prior to the call.
The sample code below demonstrates that the DDR and Port registers are set correctly by a call to PutPin() with zxOutputToggle. If you comment out the first two lines of Main(), you'll see that the pin remains an input.
| Code: | Dim pin as Byte = 12
Sub portStatus(ByVal s as String)
Debug.Print s
Debug.Print "DDRC = 0x"; CStrHex(Register.DDRC); ", PortC = 0x"; CStrHex(Register.PortC)
Debug.Print
End Sub
Sub Main()
Call portStatus("Before zxOutputLow")
Call PutPin(pin, zxOutputLow)
Call portStatus("After zxOutputLow")
Call PutPin(pin, zxOutputToggle)
Call portStatus("After zxOutputToggle")
Call PutPin(pin, zxOutputToggle)
Call portStatus("After zxOutputToggle")
End Sub
|
|
|
| Back to top |
|
 |
pjc30943
Joined: 02 Dec 2005
|
|
Posted: 24 July 2008, 20:13 PM Post subject: |
|
|
You're right, that's what it sounds like. However, the pin was set to 0 beforehand.
A 100k pulldown solves the problem, however.
I'll look through the code again later and post again. |
|
| Back to top |
|
 |
|